mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-17 22:32:26 +08:00
Merge 81a06fc6298afd02b764381b99ef5f6d7f34f960 into e72e584d1abae00fb42ef9aba1ea262c062ba2dc
This commit is contained in:
commit
54a9cda184
19
context.go
19
context.go
@ -78,6 +78,9 @@ type Context struct {
|
|||||||
// SameSite allows a server to define a cookie attribute making it impossible for
|
// SameSite allows a server to define a cookie attribute making it impossible for
|
||||||
// the browser to send this cookie along with cross-site requests.
|
// the browser to send this cookie along with cross-site requests.
|
||||||
sameSite http.SameSite
|
sameSite http.SameSite
|
||||||
|
|
||||||
|
// Method initQueryCache is only called once
|
||||||
|
initQueryCacheOnce sync.Once
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************/
|
/************************************/
|
||||||
@ -96,6 +99,7 @@ func (c *Context) reset() {
|
|||||||
c.Accepted = nil
|
c.Accepted = nil
|
||||||
c.queryCache = nil
|
c.queryCache = nil
|
||||||
c.formCache = nil
|
c.formCache = nil
|
||||||
|
c.initQueryCacheOnce = sync.Once{}
|
||||||
*c.params = (*c.params)[0:0]
|
*c.params = (*c.params)[0:0]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,6 +117,7 @@ func (c *Context) Copy() *Context {
|
|||||||
cp.index = abortIndex
|
cp.index = abortIndex
|
||||||
cp.handlers = nil
|
cp.handlers = nil
|
||||||
cp.Keys = map[string]interface{}{}
|
cp.Keys = map[string]interface{}{}
|
||||||
|
cp.initQueryCacheOnce = sync.Once{}
|
||||||
for k, v := range c.Keys {
|
for k, v := range c.Keys {
|
||||||
cp.Keys[k] = v
|
cp.Keys[k] = v
|
||||||
}
|
}
|
||||||
@ -431,13 +436,15 @@ func (c *Context) QueryArray(key string) []string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Context) initQueryCache() {
|
func (c *Context) initQueryCache() {
|
||||||
if c.queryCache == nil {
|
c.initQueryCacheOnce.Do(func() {
|
||||||
if c.Request != nil {
|
if c.queryCache == nil {
|
||||||
c.queryCache = c.Request.URL.Query()
|
if c.Request != nil {
|
||||||
} else {
|
c.queryCache = c.Request.URL.Query()
|
||||||
c.queryCache = url.Values{}
|
} else {
|
||||||
|
c.queryCache = url.Values{}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetQueryArray returns a slice of strings for a given query key, plus
|
// GetQueryArray returns a slice of strings for a given query key, plus
|
||||||
|
Loading…
x
Reference in New Issue
Block a user