From 10b526ed86dbf681b9c9a15c0079d9a229c7a5e7 Mon Sep 17 00:00:00 2001 From: Nitish Tiwari Date: Sun, 27 Oct 2019 21:19:16 +0530 Subject: [PATCH] Fix panic during trace requests (#8448) While Tracing requests on server, type assertion on logger.ResponseWriter caused nil pointer exception because of recordAPIStats{} being used as ResponseWriter. This PR avoids the type assertion and initializes a new logger.ResponseWriter. Fixes regression introduced in #8003 --- cmd/http-tracer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/http-tracer.go b/cmd/http-tracer.go index be22e6748..564543d07 100644 --- a/cmd/http-tracer.go +++ b/cmd/http-tracer.go @@ -130,7 +130,7 @@ func Trace(f http.HandlerFunc, logBody bool, w http.ResponseWriter, r *http.Requ Headers: reqHeaders, Body: reqBodyRecorder.Data(), } - rw, _ := w.(*logger.ResponseWriter) + rw := logger.NewResponseWriter(w) rw.LogBody = logBody f(rw, r)