Skip to content

Query

For query processing, you can use Query type. It provides a few useful extra methods to operate with query.

Usage:

go
// httpx.Query is a url.Values sub type, so we are wrapping a url.Values with it.
query := httpx.Query(r.URL.Query())

// With a Query wrapper we can use Unmarshal method to unmarshal query values into a struct.
type QueryParams struct {
	Foo string `query:"foo"`
	Bar string `query:"bar"`
}
var params QueryParams
err := query.Unmarshal(&params)