just use an additional log to prevent races on *req value due to cancel situation
@@ -62,7 +62,7 @@ func (e *Endpoint) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
var (
clientres *http.Response
err error
- log = e.log.WithField("uid", req.Context().Value(request.UID))
+ log = e.log.WithContext(req.Context())
isErrHandler = strings.HasPrefix(e.opts.LogHandlerKind, "error_") // weak ref
)
@@ -105,7 +105,7 @@ func (e *Endpoint) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
select {
case <-req.Context().Done():
err = req.Context().Err()
- *req = *req.WithContext(context.WithValue(req.Context(), request.Error, errors.ClientRequest.With(err)))
+ log.WithError(errors.ClientRequest.With(err)).Error()
return
default:
}
