mirror of https://github.com/gin-gonic/gin.git
parent
84bae816a0
commit
0d9e3d19af
|
@ -268,13 +268,11 @@ func (c *Context) Get(key string) (value any, exists bool) {
|
||||||
// GetAs returns the value for the given key, ie: (value, true).
|
// GetAs returns the value for the given key, ie: (value, true).
|
||||||
// If the value does not exist it returns (nil, false)
|
// If the value does not exist it returns (nil, false)
|
||||||
func (c *Context) GetAs[T any](key string) (result T, exists bool) {
|
func (c *Context) GetAs[T any](key string) (result T, exists bool) {
|
||||||
c.mu.RLock()
|
value, exists := c.Get(key)
|
||||||
value, exists := c.Keys[key]
|
|
||||||
c.mu.RUnlock()
|
|
||||||
|
|
||||||
if !exists {
|
if !exists {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
result, exists = value.(T)
|
result, exists = value.(T)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue