Log the whole request path
Next handlers might cut up request’s URL.Path, so i need to keep a copy before calling next to log the whole thing.
This commit is contained in:
parent
ebe8217862
commit
b0317f1051
|
@ -38,6 +38,7 @@ func LogRequest(next http.Handler) http.Handler {
|
||||||
t := time.Now()
|
t := time.Now()
|
||||||
logger := loggerResponseWriter{w, 0, 0}
|
logger := loggerResponseWriter{w, 0, 0}
|
||||||
|
|
||||||
|
requestPath := r.URL.Path
|
||||||
next.ServeHTTP(&logger, r)
|
next.ServeHTTP(&logger, r)
|
||||||
|
|
||||||
statusCode := logger.statusCode
|
statusCode := logger.statusCode
|
||||||
|
@ -47,7 +48,7 @@ func LogRequest(next http.Handler) http.Handler {
|
||||||
log.Printf("HTTP - %s %s \"%s\" %d %d %s\n",
|
log.Printf("HTTP - %s %s \"%s\" %d %d %s\n",
|
||||||
RemoteAddr(r),
|
RemoteAddr(r),
|
||||||
r.Method,
|
r.Method,
|
||||||
r.URL.Path,
|
requestPath,
|
||||||
statusCode,
|
statusCode,
|
||||||
logger.responseSize,
|
logger.responseSize,
|
||||||
time.Since(t),
|
time.Since(t),
|
||||||
|
|
Loading…
Reference in New Issue