Query Parameters
Query paramaters are a defined set of paramaters attached to the end of a URL. They are extensions of the URL that are used to help define specific content or actions based on the data being passed.
For example, the following query string specifies a query parameter named name
with a value of John
:
Additional parameters can be added by using the &
character:
Decoding Query Parameters
Much like form data, query parameters can be decoded from the incoming http.Request
into a struct type for statically typed access and validation using the generic function:
One can use the json
struct tags to define the names of the valid query parameters.
The following is an example of a Loader
that decodes query parameters and uses them to search for users in a database, returning the results: