Skip to main content
Extractor that deserializes query strings into some type. The type parameter T must implement serde::Deserialize.

Type signature

Usage

Basic example

Optional query parameters

Use Option fields in your struct to make query parameters optional:

Default values

Combine with #[serde(default)] for default values:

Multiple values

Query parameters with the same name can be collected into a Vec:

Error handling

QueryRejection
Returned when the query string cannot be parsed into the target type.
If the query string cannot be deserialized, the request will be rejected with a 400 Bad Request response.

Parsing from URI

You can also parse query parameters directly from a Uri:

Form URL encoding

Query strings use the same encoding as application/x-www-form-urlencoded form data. Special characters are percent-encoded: