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
master
Nitish Tiwari 5 years ago committed by Harshavardhana
parent 980bf78b4d
commit 10b526ed86
  1. 2
      cmd/http-tracer.go

@ -130,7 +130,7 @@ func Trace(f http.HandlerFunc, logBody bool, w http.ResponseWriter, r *http.Requ
Headers: reqHeaders, Headers: reqHeaders,
Body: reqBodyRecorder.Data(), Body: reqBodyRecorder.Data(),
} }
rw, _ := w.(*logger.ResponseWriter) rw := logger.NewResponseWriter(w)
rw.LogBody = logBody rw.LogBody = logBody
f(rw, r) f(rw, r)

Loading…
Cancel
Save