Documentation
¶
Overview ¶
Package searchparams decodes URL search parameters into Go structs and derives a type-level schema describing the accepted shape.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Parse/ParseInto errors. ErrCannotParse = errors.New("error parsing URL search parameters") ErrNilRequest = errors.New("parse: request is nil") ErrNilURL = errors.New("parse: request URL is nil") ErrNilDest = errors.New("parse: destination must be a non-nil pointer") ErrNonStructDest = errors.New("parse: destination must point to a struct") // SchemaFromValue errors. ErrInvalidSchema = errors.New("invalid URL search params schema") ErrNilValueInSchema = errors.New("schema: value cannot be nil") ErrNonStructRoot = errors.New("schema: root must be a struct") )
Functions ¶
func ParseIntoStructPtr ¶
ParseIntoStructPtr parses URL search parameters from an HTTP request into the struct pointed to by dest. Used when the destination type is only known at runtime (e.g. via reflection-based type erasure). Callers with a static type should prefer ParseToStruct.
Types ¶
type Schema ¶
type Schema any
Schema describes the accepted shape of a decoded struct. Node types are:
- string codes ("s", "n", "b") for scalars, optionally prefixed with "?" to mark pointer scalars.
- []Schema{elem} for slices and arrays.
- []Schema{"*", val} for maps with string keys.
- map[string]Schema for structs.
func SchemaFromValue ¶
SchemaFromValue derives a Schema from the type of value. The value's runtime contents are ignored; only its type is inspected. The root must be a struct (or a pointer to one).
Click to show internal directories.
Click to hide internal directories.