From: Brian Brazil Date: Fri, 16 Aug 2019 12:58:30 +0000 (+0100) Subject: Use HTTP request's context, so cancellation works. (#510) X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=64308dde3a90b580b1d9102a390cd737b694cb63;p=blackbox_exporter.git Use HTTP request's context, so cancellation works. (#510) Signed-off-by: Brian Brazil --- diff --git a/main.go b/main.go index 509e62e..e4f9b75 100644 --- a/main.go +++ b/main.go @@ -77,7 +77,7 @@ func probeHandler(w http.ResponseWriter, r *http.Request, c *config.Config, logg return } - ctx, cancel := context.WithTimeout(context.Background(), time.Duration(timeoutSeconds*float64(time.Second))) + ctx, cancel := context.WithTimeout(r.Context(), time.Duration(timeoutSeconds*float64(time.Second))) defer cancel() r = r.WithContext(ctx)