MCPcopy
hub / github.com/gin-gonic/gin / GetQuery

Method GetQuery

context.go:554–559  ·  view source on GitHub ↗

GetQuery is like Query(), it returns the keyed url query value if it exists `(value, true)` (even when the value is an empty string), otherwise it returns `("", false)`. It is shortcut for `c.Request.URL.Query().Get(key)` GET /?name=Manu&lastname= ("Manu", true) == c.GetQuery("name") ("", false)

(key string)

Source from the content-addressed store, hash-verified

552// ("", false) == c.GetQuery("id")
553// ("", true) == c.GetQuery("lastname")
554func (c *Context) GetQuery(key string) (string, bool) {
555 if values, ok := c.GetQueryArray(key); ok {
556 return values[0], ok
557 }
558 return "", false
559}
560
561// QueryArray returns a slice of strings for a given query key.
562// The length of the slice depends on the number of params with the given key.

Callers 6

QueryMethod · 0.95
DefaultQueryMethod · 0.95
TestContextQueryFunction · 0.80

Calls 1

GetQueryArrayMethod · 0.95

Tested by 4

TestContextQueryFunction · 0.64