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

Method DefaultQuery

context.go:538–543  ·  view source on GitHub ↗

DefaultQuery returns the keyed url query value if it exists, otherwise it returns the specified defaultValue string. See: Query() and GetQuery() for further information. GET /?name=Manu&lastname= c.DefaultQuery("name", "unknown") == "Manu" c.DefaultQuery("id", "none") == "none" c.DefaultQuery("

(key, defaultValue string)

Source from the content-addressed store, hash-verified

536// c.DefaultQuery("id", "none") == "none"
537// c.DefaultQuery("lastname", "none") == ""
538func (c *Context) DefaultQuery(key, defaultValue string) string {
539 if value, ok := c.GetQuery(key); ok {
540 return value
541 }
542 return defaultValue
543}
544
545// GetQuery is like Query(), it returns the keyed url query value
546// if it exists `(value, true)` (even when the value is an empty string),

Callers 5

JSONPMethod · 0.95
TestContextQueryFunction · 0.80

Calls 1

GetQueryMethod · 0.95

Tested by 4

TestContextQueryFunction · 0.64