Expand description
FromRequest — typed extractors for controller actions.
A controller signature says what it needs and the framework supplies it, with the types doing the describing:
ⓘ
async fn store(Json(post): Json<NewPost>, Query(page): Query<Pagination>) -> ResponseEvery extractor takes Arc<Request> and returns a 'static future. Sharing
one Arc is what lets several extractors read the same request
concurrently-shaped without cloning it or fighting over a borrow, and the
'static future is what lets the router store handlers of many different
shapes in one table.
Extraction is async because some extractors genuinely need to be: route
model binding loads a record from the database, and an authenticated-user
extractor asks the guard. Those live in rainier-database and
rainier-auth respectively; the ones here need no I/O but share the shape.
Structs§
- Bearer
- The
Authorization: Bearer …token. - Files
- Every file uploaded under a named field. Empty when none arrived.
- Form
- The merged request input (query string plus body), deserialised with string
coercion — so a urlencoded
page=2fills au32field. - Header
- A named header’s value, required.
- Json
- The JSON request body, deserialised.
- Path
- The route parameters, deserialised with string coercion.
- Query
- The query string, deserialised with string coercion.
- RawBody
- The raw request body.
Traits§
- From
Request - Something a handler parameter can be built from.
- Static
Name - A compile-time name for an extractor that needs one — a header, a form field.