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()
|
||||
logger := loggerResponseWriter{w, 0, 0}
|
||||
|
||||
requestPath := r.URL.Path
|
||||
next.ServeHTTP(&logger, r)
|
||||
|
||||
statusCode := logger.statusCode
|
||||
|
@ -47,7 +48,7 @@ func LogRequest(next http.Handler) http.Handler {
|
|||
log.Printf("HTTP - %s %s \"%s\" %d %d %s\n",
|
||||
RemoteAddr(r),
|
||||
r.Method,
|
||||
r.URL.Path,
|
||||
requestPath,
|
||||
statusCode,
|
||||
logger.responseSize,
|
||||
time.Since(t),
|
||||
|
|
Loading…
Reference in New Issue