mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-16 05:16:35 +08:00
Merge 7cdb8065f4809bab29a3a6d55bbd98058671f1d0 into 51aea73ba0f125f6cacc3b4b695efdf21d9c634f
This commit is contained in:
commit
55545bc648
@ -1210,7 +1210,7 @@ func (c *Context) Value(key any) any {
|
||||
return val
|
||||
}
|
||||
}
|
||||
if !c.engine.ContextWithFallback || c.Request == nil || c.Request.Context() == nil {
|
||||
if c.engine != nil && !c.engine.ContextWithFallback || c.Request == nil || c.Request.Context() == nil {
|
||||
return nil
|
||||
}
|
||||
return c.Request.Context().Value(key)
|
||||
|
@ -2354,3 +2354,9 @@ func TestContextAddParam(t *testing.T) {
|
||||
assert.Equal(t, ok, true)
|
||||
assert.Equal(t, value, v)
|
||||
}
|
||||
|
||||
func TestRetrieveValueNoEngineInContext(t *testing.T) {
|
||||
c := &Context{}
|
||||
v := c.Value("foo")
|
||||
assert.Nil(t, v)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user