chore: rename getQueryCache/getFormCache to initQueryCache/initFormCache (#2375)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by thinkerou · committed by GitHub · parent a6e8665 · Browse files · 2 files·+12 added−13 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+12 added−13 removed
- other:+12 added−13 removed
Provenance
- Commit
1d5b9ba- Tree
1448360- Author
thinkerou <thinkerou@gmail.com>- Committer
GitHub <noreply@github.com>- Parent
a6e8665
2 files changed+12 added−13 removed
modified:context.go+6 added-6 removed
412 unmodified lines413 values, _ := c.GetQueryArray(key)414 return values415 }416 417-func (c *Context) getQueryCache() {417+func (c *Context) initQueryCache() {418 if c.queryCache == nil {419 c.queryCache = c.Request.URL.Query()420 }421 }422 423 // GetQueryArray returns a slice of strings for a given query key, plus424 // a boolean value whether at least one value exists for the given key.425 func (c *Context) GetQueryArray(key string) ([]string, bool) {426- c.getQueryCache()426+ c.initQueryCache()427 if values, ok := c.queryCache[key]; ok && len(values) > 0 {428 return values, true429 }430 return []string{}, false7 unmodified lines438 439 // GetQueryMap returns a map for a given query key, plus a boolean value440 // whether at least one value exists for the given key.441 func (c *Context) GetQueryMap(key string) (map[string]string, bool) {442- c.getQueryCache()442+ c.initQueryCache()443 return c.get(c.queryCache, key)444 }445 446 // PostForm returns the specified key from a POST urlencoded form or multipart form33 unmodified lines480 values, _ := c.GetPostFormArray(key)481 return values482 }483 484-func (c *Context) getFormCache() {484+func (c *Context) initFormCache() {485 if c.formCache == nil {486 c.formCache = make(url.Values)487 req := c.Request488 if err := req.ParseMultipartForm(c.engine.MaxMultipartMemory); err != nil {7 unmodified lines496 497 // GetPostFormArray returns a slice of strings for a given form key, plus498 // a boolean value whether at least one value exists for the given key.499 func (c *Context) GetPostFormArray(key string) ([]string, bool) {500- c.getFormCache()500+ c.initFormCache()501 if values := c.formCache[key]; len(values) > 0 {502 return values, true503 }504 return []string{}, false7 unmodified lines512 513 // GetPostFormMap returns a map for a given form key, plus a boolean value514 // whether at least one value exists for the given key.515 func (c *Context) GetPostFormMap(key string) (map[string]string, bool) {516- c.getFormCache()516+ c.initFormCache()517 return c.get(c.formCache, key)518 }519 520 // get is an internal method and returns a map which satisfy conditions.590 unmodified linesmodified:utils.go+6 added-7 removed
88 unmodified lines89 return content90 }91 92 func chooseData(custom, wildcard interface{}) interface{} {93- if custom == nil {94- if wildcard == nil {95- panic("negotiation config is invalid")96- }93+ if custom != nil {94+ return custom95+ }96+ if wildcard != nil {97 return wildcard98 }99- return custom99+ panic("negotiation config is invalid")100 }101 102 func parseAccept(acceptHeader string) []string {103 parts := strings.Split(acceptHeader, ",")22 unmodified lines126 return absolutePath127 }128 129 finalPath := path.Join(absolutePath, relativePath)130- appendSlash := lastChar(relativePath) == '/' && lastChar(finalPath) != '/'131- if appendSlash {130+ if lastChar(relativePath) == '/' && lastChar(finalPath) != '/' {131 return finalPath + "/"132 }133 return finalPath134 }16 unmodified lines