Skip to content
Myr

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

2 files+12 added−13 removed

modified:context.go+6 added-6 removed
412 unmodified lines
413 values, _ := c.GetQueryArray(key)414 return values415}416417func (c *Context) getQueryCache() {417func (c *Context) initQueryCache() {418 if c.queryCache == nil {419 c.queryCache = c.Request.URL.Query()420 }421}422423// 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.425func (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{}, false
7 unmodified lines
438439// GetQueryMap returns a map for a given query key, plus a boolean value440// whether at least one value exists for the given key.441func (c *Context) GetQueryMap(key string) (map[string]string, bool) {442 c.getQueryCache()442 c.initQueryCache()443 return c.get(c.queryCache, key)444}445446// PostForm returns the specified key from a POST urlencoded form or multipart form
33 unmodified lines
480 values, _ := c.GetPostFormArray(key)481 return values482}483484func (c *Context) getFormCache() {484func (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 lines
496497// 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.499func (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{}, false
7 unmodified lines
512513// GetPostFormMap returns a map for a given form key, plus a boolean value514// whether at least one value exists for the given key.515func (c *Context) GetPostFormMap(key string) (map[string]string, bool) {516 c.getFormCache()516 c.initFormCache()517 return c.get(c.formCache, key)518}519520// get is an internal method and returns a map which satisfy conditions.
590 unmodified lines
modified:utils.go+6 added-7 removed
88 unmodified lines
89 return content90}9192func 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}101102func parseAccept(acceptHeader string) []string {103 parts := strings.Split(acceptHeader, ",")
22 unmodified lines
126 return absolutePath127 }128129 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