Skip to main content

Module interceptors

Module interceptors 

Source
Expand description

Aspect-oriented interceptors.

An Interceptor sits around a handler: it sees the inbound RequestContext before extraction and the Response on the way out. Use it for logging, timing, response envelopes, caching — anything that shouldn’t live in handler bodies.

Apply with the #[UseInterceptors(...)] attribute on a handler or controller impl block. Multiple interceptors compose in declaration order (first listed = outermost layer).

Structs§

EnvelopeResponse
Wrap successful JSON responses in { "data": ... }. Errors pass through untouched so RFC 7807 ProblemDetails reaches the client verbatim.
LatencyLog
Log method + path + status + latency on each request.
NextHandler
Continuation handed to an interceptor. Calling .run(ctx) invokes the next layer (or the handler itself if this is the innermost interceptor).
TelemetryLog
Emit a structured log line for every request via the tracing crate.
TraceInterceptor
Full-stack observability interceptor: structured log + OTLP span + Prometheus.

Traits§

Interceptor
One layer of the aspect chain.