Web: Preserve context from request (#5404)

The `http.Request` object can already have a context associated
with it. If it does, preserve that context rather than creating a new
one. If it doesn't, create a new `context.Background` instead.
This commit is contained in:
Aaron Gable 2021-04-29 14:20:54 -07:00 committed by GitHub
parent 7bf854fe03
commit d59e715c9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 2 deletions

View File

@ -57,8 +57,7 @@ func (e *RequestEvent) AddError(msg string, args ...interface{}) {
type WFEHandlerFunc func(context.Context, *RequestEvent, http.ResponseWriter, *http.Request)
func (f WFEHandlerFunc) ServeHTTP(e *RequestEvent, w http.ResponseWriter, r *http.Request) {
ctx := context.TODO()
f(ctx, e, w, r)
f(r.Context(), e, w, r)
}
type wfeHandler interface {