There's probably something obvious that I'm missing but I'm trying to extract the data already written after the return of a chained handler.
func Logger(next http.Handler, name string) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
start := time.Now()
next.ServeHTTP(w, r)
log.Debug(
fmt.Sprintf("%s %s %s %s",
r.Method,
r.RequestURI,
name,
time.Since(start)),
)
})
}
After the next.ServeHTTP function returns I already have the data and I want just to check some values at the response before logging the entire request. I cannot find a way to extra the data from http.ResponseWriter.
Do I miss something ?