Skip to main content

Module extract

Module extract 

Source
Expand description

Request context and extractors (spec §4.1). Everything a handler needs is visible in its signature; each parameter implements FromRequest.

Structs§

ClientAddr
The connection’s remote socket address, threaded from the accept loop onto parts.extensions so it survives into the handler. A newtype so the typemap lookup is unambiguous. None for synthetic requests (tasks, some tests).
Headers
Read-only access to request headers in a handler signature.
Path
Typed path parameter: Path<i64> binds the LEAF-MOST (last) captured parameter; use a tuple to address all parameters root→leaf — Path<(A, B)> / Path<(A, B, C)> grab two/three {param}s in route order. Param types are the sealed PathParam set (integers, String, bool, floats, char); custom newtypes opt in through the path_param! macro.
PathParams
A by-name view of the request’s captured path parameters. Where Path<T> binds positionally (the leaf-most segment, or a root→leaf tuple), PathParams reads a SPECIFIC mount param BY NAME — the accessor a DI factory needs, since a factory resolves each argument through FromRequest and cannot borrow &RequestCtx to call RequestCtx::param. The membership-verifying tenancy guard uses it to read the tenant fk club_id under /clubs/{club_id} even when a leaf {id} follows (issues #78/#79). Rejects a task context (JC1003), like every other HTTP-coupled extractor.
Query
Typed query string: Query<MyParams> via serde.
RawBody
The request body as EXACT bytes — the extractor for webhook signature verification, where the digest must cover the wire bytes, not a re-serialized value. Works on buffered routes (cheap clone) and stream_body() routes (drains and caches). See the auth docs for the Stripe/Twilio recipes.
RequestCtx
The mutable view of one in-flight request. Handlers receive extractors, not this type; middleware and the DI resolver work through it.

Traits§

FromRequest
Types that can be produced from the request. Implemented by all extractors and by Dep<T> (see dep module).
PathParam
Types extractable from one path segment. The built-in set (integers, String, bool, floats, char) is sealed; custom param types (id newtypes) join it through the path_param! macro, which is the only sanctioned way to implement this trait outside the crate.