skip http request logging when the client aborts the request (#3195)

* skip http request logging when the client aborts the request

* cleanup
This commit is contained in:
Paul Wells
2024-11-22 00:42:49 -08:00
committed by GitHub
parent a83a7abcf4
commit 29c7906250

View File

@@ -31,7 +31,7 @@ func handleError(w http.ResponseWriter, r *http.Request, status int, err error,
if r != nil && r.URL != nil {
keysAndValues = append(keysAndValues, "method", r.Method, "path", r.URL.Path)
}
if !errors.Is(err, context.Canceled) {
if !errors.Is(err, context.Canceled) && !errors.Is(r.Context().Err(), context.Canceled) {
logger.GetLogger().WithCallDepth(1).Warnw("error handling request", err, keysAndValues...)
}
w.WriteHeader(status)