Add RequestID middleware for tracing and enhance logging with request IDs
This commit is contained in:
@ -26,8 +26,11 @@ func Logging(next http.Handler) http.Handler {
|
||||
statusCode: http.StatusOK,
|
||||
}
|
||||
|
||||
// Get request ID from header (set by RequestID middleware)
|
||||
requestID := r.Header.Get(RequestIDHeader)
|
||||
|
||||
next.ServeHTTP(wrapped, r)
|
||||
|
||||
log.Println(wrapped.statusCode, r.Method, r.URL.Path, time.Since(start))
|
||||
log.Printf("[%s] %d %s %s %v", requestID, wrapped.statusCode, r.Method, r.URL.Path, time.Since(start))
|
||||
})
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user