Skip to main content

Module middleware

Module middleware 

Source
Expand description

Built-in middleware. Each piece is an async function with the signature async fn(Request, Next) -> Result<Response>. Drop any of them into Router::middleware(...) in whatever order you want.

Structs§

CorrelationId
Wrapper carried in the request context so handlers can pull it out via req.ctx().get::<CorrelationId>(). The inner string is the UUID rendered in hyphenated lowercase form.
CsrfGuard
A value a handler can pull out of the request context to embed in a rendered form. Lightweight; just wraps a string.
RateLimiter

Constants§

CORRELATION_ID_HEADER
Response + request header name. Lower-case to keep parity with the HTTP/2 wire format and to match what other observability tooling (OpenTelemetry, Cloudflare, etc.) writes.
CSRF_HEADER

Functions§

correlation_id
Middleware: attach a UUID v7 to every request, surface it in the response, and stash it in the request context for the audit pipeline to pick up.
csrf_protect
gzip
logger
rate_limit
The middleware function. Wrap a limiter into a closure and hand it to Router::middleware(...).
security_headers