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

Function QueryParam

binder_generic.go:114–130  ·  view source on GitHub ↗

QueryParam extracts and parses a single query parameter from the request by key. It returns the typed value and an error if binding fails. Returns ErrNonExistentKey if parameter not found. Empty String Handling: If the parameter exists but has an empty value (?key=), the zero value of type T is r

(c *Context, key string, opts ...any)

Source from the content-addressed store, hash-verified

112//
113// See ParseValue for supported types and options
114func QueryParam[T any](c *Context, key string, opts ...any) (T, error) {
115 values, ok := c.QueryParams()[key]
116 if !ok {
117 var zero T
118 return zero, ErrNonExistentKey
119 }
120 if len(values) == 0 {
121 var zero T
122 return zero, nil
123 }
124 value := values[0]
125 v, err := ParseValue[T](value, opts...)
126 if err != nil {
127 return v, NewBindingError(key, []string{value}, "query param", err)
128 }
129 return v, nil
130}
131
132// QueryParamOr extracts and parses a single query parameter from the request by key.
133// Returns defaultValue if the parameter is not found or has an empty value.

Callers 1

Calls 2

NewBindingErrorFunction · 0.85
QueryParamsMethod · 0.80

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…