-
Notifications
You must be signed in to change notification settings - Fork 476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
disconnect context in a dedicated middleware #315
Conversation
To be honest, I am not a huge fan of since since it complicates the request flow even more. Instead, I could think of a creating a new background context which inherits the values from the request's context. Something like this: type contextWithValues struct {
context.Context
valueHolder context.Context
}
func (c contextWithValues) Value(key interface{}) interface{} {
return c.valueHolder.Value(key)
}
ctxForStorage := contextWithValues{
// Use background to not get cancel event
Context: context.Background(),
// Use request context to get stored values
valueHolder: request.Context(),
}
This would also be a problem since we promised to support Go 1.12 until Go 1.14 has been released: https://github.com/tus/tusd/blob/master/docs/installation.md |
Move disconnecting the context to a separate middleware. Deprecates #309
This allows customizing the context that is used for the request handlers by implementing a custom middleware that can eg also add opentracing or other context information.
requires go 1.13 to do a deep copy of the request: https://golang.org/pkg/net/http/#Request.Clone see golang/go#23544 for duscussion and golang/go@f5c43b9 for the commit