mirror of https://github.com/gin-gonic/gin.git
chore: rename getQueryCache/getFormCache to initQueryCache/initFormCache (#2375)
This commit is contained in:
parent
a6e8665e42
commit
1d5b9badd9
12
context.go
12
context.go
|
@ -414,7 +414,7 @@ func (c *Context) QueryArray(key string) []string {
|
||||||
return values
|
return values
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Context) getQueryCache() {
|
func (c *Context) initQueryCache() {
|
||||||
if c.queryCache == nil {
|
if c.queryCache == nil {
|
||||||
c.queryCache = c.Request.URL.Query()
|
c.queryCache = c.Request.URL.Query()
|
||||||
}
|
}
|
||||||
|
@ -423,7 +423,7 @@ func (c *Context) getQueryCache() {
|
||||||
// GetQueryArray returns a slice of strings for a given query key, plus
|
// GetQueryArray returns a slice of strings for a given query key, plus
|
||||||
// a boolean value whether at least one value exists for the given key.
|
// a boolean value whether at least one value exists for the given key.
|
||||||
func (c *Context) GetQueryArray(key string) ([]string, bool) {
|
func (c *Context) GetQueryArray(key string) ([]string, bool) {
|
||||||
c.getQueryCache()
|
c.initQueryCache()
|
||||||
if values, ok := c.queryCache[key]; ok && len(values) > 0 {
|
if values, ok := c.queryCache[key]; ok && len(values) > 0 {
|
||||||
return values, true
|
return values, true
|
||||||
}
|
}
|
||||||
|
@ -439,7 +439,7 @@ func (c *Context) QueryMap(key string) map[string]string {
|
||||||
// GetQueryMap returns a map for a given query key, plus a boolean value
|
// GetQueryMap returns a map for a given query key, plus a boolean value
|
||||||
// whether at least one value exists for the given key.
|
// whether at least one value exists for the given key.
|
||||||
func (c *Context) GetQueryMap(key string) (map[string]string, bool) {
|
func (c *Context) GetQueryMap(key string) (map[string]string, bool) {
|
||||||
c.getQueryCache()
|
c.initQueryCache()
|
||||||
return c.get(c.queryCache, key)
|
return c.get(c.queryCache, key)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -481,7 +481,7 @@ func (c *Context) PostFormArray(key string) []string {
|
||||||
return values
|
return values
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Context) getFormCache() {
|
func (c *Context) initFormCache() {
|
||||||
if c.formCache == nil {
|
if c.formCache == nil {
|
||||||
c.formCache = make(url.Values)
|
c.formCache = make(url.Values)
|
||||||
req := c.Request
|
req := c.Request
|
||||||
|
@ -497,7 +497,7 @@ func (c *Context) getFormCache() {
|
||||||
// GetPostFormArray returns a slice of strings for a given form key, plus
|
// GetPostFormArray returns a slice of strings for a given form key, plus
|
||||||
// a boolean value whether at least one value exists for the given key.
|
// a boolean value whether at least one value exists for the given key.
|
||||||
func (c *Context) GetPostFormArray(key string) ([]string, bool) {
|
func (c *Context) GetPostFormArray(key string) ([]string, bool) {
|
||||||
c.getFormCache()
|
c.initFormCache()
|
||||||
if values := c.formCache[key]; len(values) > 0 {
|
if values := c.formCache[key]; len(values) > 0 {
|
||||||
return values, true
|
return values, true
|
||||||
}
|
}
|
||||||
|
@ -513,7 +513,7 @@ func (c *Context) PostFormMap(key string) map[string]string {
|
||||||
// GetPostFormMap returns a map for a given form key, plus a boolean value
|
// GetPostFormMap returns a map for a given form key, plus a boolean value
|
||||||
// whether at least one value exists for the given key.
|
// whether at least one value exists for the given key.
|
||||||
func (c *Context) GetPostFormMap(key string) (map[string]string, bool) {
|
func (c *Context) GetPostFormMap(key string) (map[string]string, bool) {
|
||||||
c.getFormCache()
|
c.initFormCache()
|
||||||
return c.get(c.formCache, key)
|
return c.get(c.formCache, key)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
11
utils.go
11
utils.go
|
@ -90,13 +90,13 @@ func filterFlags(content string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func chooseData(custom, wildcard interface{}) interface{} {
|
func chooseData(custom, wildcard interface{}) interface{} {
|
||||||
if custom == nil {
|
if custom != nil {
|
||||||
if wildcard == nil {
|
return custom
|
||||||
panic("negotiation config is invalid")
|
|
||||||
}
|
}
|
||||||
|
if wildcard != nil {
|
||||||
return wildcard
|
return wildcard
|
||||||
}
|
}
|
||||||
return custom
|
panic("negotiation config is invalid")
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseAccept(acceptHeader string) []string {
|
func parseAccept(acceptHeader string) []string {
|
||||||
|
@ -127,8 +127,7 @@ func joinPaths(absolutePath, relativePath string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
finalPath := path.Join(absolutePath, relativePath)
|
finalPath := path.Join(absolutePath, relativePath)
|
||||||
appendSlash := lastChar(relativePath) == '/' && lastChar(finalPath) != '/'
|
if lastChar(relativePath) == '/' && lastChar(finalPath) != '/' {
|
||||||
if appendSlash {
|
|
||||||
return finalPath + "/"
|
return finalPath + "/"
|
||||||
}
|
}
|
||||||
return finalPath
|
return finalPath
|
||||||
|
|
Loading…
Reference in New Issue