Skip to main content

Module middleware

Module middleware 

Source
Expand description

Composable middleware pipeline for request processing.

Provides a MiddlewarePipeline that executes a chain of Middleware implementations in order. Each middleware can inspect/modify the RequestContext, optionally short-circuit the pipeline (e.g. on auth failure), or let processing continue by calling Next::run.

§Built-in middleware

MiddlewarePurpose
LoggingMiddlewareLogs request/response with duration
MetricsMiddlewareRecords operation metrics
AuthMiddlewareAPI-key / JWT authentication
RateLimitMiddlewareToken-bucket rate limiting
TracingMiddlewareCreates a tracing span per request

Structs§

AuthMiddleware
Validates authentication credentials found in request metadata.
LoggingMiddleware
Logs every request and its outcome.
MetricsMiddleware
Records request metrics via the existing MetricsCollector.
MiddlewarePipeline
An immutable, ordered pipeline of middleware.
MiddlewarePipelineBuilder
Builder for MiddlewarePipeline.
RateLimitMiddleware
Simple token-bucket rate limiter.
RequestContext
Context that travels through the middleware pipeline.
Response
Response wrapper returned by the middleware pipeline.
TracingMiddleware
Creates a tracing span around the remainder of the pipeline.

Enums§

LogLevel
Log verbosity used by LoggingMiddleware.
MiddlewareError
Errors that can occur in the middleware pipeline.
ResponseStatus
Status of a middleware response.

Traits§

Middleware
Trait implemented by each middleware layer.
Next
Trait for the “rest of the pipeline” that a middleware calls to continue.

Type Aliases§

Result