context: allow nil request context in fetch cases
This commit is contained in:
@@ -24,7 +24,11 @@ type requestDataContextKey struct {
|
||||
}
|
||||
|
||||
func RequestDataFromContext(ctx context.Context) *RequestData {
|
||||
return ctx.Value(requestDataContextKey{}).(*RequestData)
|
||||
val := ctx.Value(requestDataContextKey{})
|
||||
if val == nil {
|
||||
return nil
|
||||
}
|
||||
return val.(*RequestData)
|
||||
}
|
||||
|
||||
type RequestId [16]byte
|
||||
|
@@ -116,8 +116,7 @@ func (b Backend) Create() (*httputil.ReverseProxy, error) {
|
||||
}
|
||||
|
||||
if !b.Transparent {
|
||||
data := challenge.RequestDataFromContext(req.Context())
|
||||
if data != nil {
|
||||
if data := challenge.RequestDataFromContext(req.Context()); data != nil {
|
||||
data.RequestHeaders(req.Header)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user