MCPcopy Index your code
hub / github.com/labstack/echo / QueryParamOr

Method QueryParamOr

context.go:375–381  ·  view source on GitHub ↗

QueryParamOr returns the query param or default value for the provided name. Note: QueryParamOr does not distinguish if query had no value by that name or value was empty string This means URLs `/test?search=` and `/test` would both return `1` for `c.QueryParamOr("search", "1")`

(name, defaultValue string)

Source from the content-addressed store, hash-verified

373// Note: QueryParamOr does not distinguish if query had no value by that name or value was empty string
374// This means URLs `/test?search=` and `/test` would both return `1` for `c.QueryParamOr("search", "1")`
375func (c *Context) QueryParamOr(name, defaultValue string) string {
376 value := c.QueryParam(name)
377 if value == "" {
378 value = defaultValue
379 }
380 return value
381}
382
383// QueryParams returns the query parameters as `url.Values`.
384func (c *Context) QueryParams() url.Values {

Callers 1

Calls 1

QueryParamMethod · 0.95

Tested by 1