MCPcopy
hub / github.com/danielgtaylor/huma / getParamValue

Function getParamValue

huma.go:1661–1679  ·  view source on GitHub ↗

getParamValue extracts the requested parameter from the relevant context or cookie source. If unset, the function returns the default value for this parameter.

(p paramFieldInfo, ctx Context, cookies map[string]*http.Cookie)

Source from the content-addressed store, hash-verified

1659// context or cookie source. If unset, the function returns the default value
1660// for this parameter.
1661func getParamValue(p paramFieldInfo, ctx Context, cookies map[string]*http.Cookie) string {
1662 var value string
1663 switch p.Loc {
1664 case "path":
1665 value = ctx.Param(p.Name)
1666 case "query":
1667 value = ctx.Query(p.Name)
1668 case "header":
1669 value = ctx.Header(p.Name)
1670 case "cookie":
1671 if c, ok := cookies[p.Name]; ok {
1672 value = c.Value
1673 }
1674 }
1675 if value == "" {
1676 value = p.Default
1677 }
1678 return value
1679}
1680
1681var errUnparsable = errors.New("unparsable value")
1682

Callers 1

RegisterFunction · 0.85

Calls 3

ParamMethod · 0.65
QueryMethod · 0.65
HeaderMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…