Expand description
Render context and extractors.
Page, layout and metadata functions declare what they need as arguments;
the generated route glue resolves each argument through FromContext:
ⓘ
pub async fn Page(Path(p): Path<PostParams>, cookies: Cookies) -> Result<impl View> { .. }Arguments that read request data (cookies, headers, query, …) make the
route dynamic under rendering = "auto".
Structs§
- Auth
- Authentication context primitive: set by your auth middleware, read by
pages.
Auth<T>isOption-like:auth.user()isNonefor guests. - Auth
User - Wrapper middleware inserts:
req.insert_extension(AuthUser(user)). - Client
Ip - The client’s IP address, read as
crate::Request::client_ipreads it: the firstX-Forwarded-Forentry when[server] trust_proxyis on, the peer address otherwise.Nonewhen neither is known (tests, pre-rendering). - Csrf
Token - CSRF token for forms when
csrf()middleware or[security] csrf = "token"is used. - Data
- Result of the route’s
loadfunction:Data(posts): Data<Vec<Post>>. - Extension
- A value inserted by middleware (
req.insert_extension(user)), e.g. the authenticated user:Extension(user): Extension<User>. Missing values produce a 500 in development with a clear message; useOption<Extension<T>>for optional values. - Form
State - Result of the last progressive-enhancement form submission (validation errors / error message), read once from a short-lived flash cookie.
- Headers
- Request headers.
- Nonce
- The per-request CSP nonce (for your own inline scripts).
- Path
- Typed route parameters:
Path(p): Path<BlogParams>. A parameter that fails to parse (e.g./users/abcforid: u64) renders the 404 page. - Query
- Parsed query string:
Query(q): Query(a map) orQuery<T>(typed). - Query
Map - Query parameters as a multi-map.
- Request
Context - Everything known about the request being rendered.
- Request
Info - Basic request information.
- Response
Headers - Add headers to the page response.
Enums§
- Render
Mode - Whether a render serves a live request or runs at build/revalidation time.
Traits§
- From
Context - Resolve a function argument from the render context.
Type Aliases§
- Ctx
- Shared handle to the context.