pub trait HttpMiddleware {
// Provided methods
fn on_request(
&self,
_context: &mut HttpRequestContext<'_>,
) -> Option<Response> { ... }
fn on_operation(
&self,
_context: &mut HttpRequestContext<'_>,
_operation: &OperationDescriptor,
_security_schemes: &[SecuritySchemeDescriptor],
) -> Option<Response> { ... }
fn on_response(
&self,
_context: &HttpRequestContext<'_>,
_operation: Option<&OperationDescriptor>,
_response: &mut Response,
) { ... }
fn verifies_security(&self) -> bool { ... }
}Expand description
Synchronous middleware interception points shared by every HTTP adapter.
Middleware is deliberately runtime-neutral: cryptographic verification, header policy, compression, and rate limiting do not require Tokio or any other async runtime.
Provided Methods§
Sourcefn on_request(&self, _context: &mut HttpRequestContext<'_>) -> Option<Response>
fn on_request(&self, _context: &mut HttpRequestContext<'_>) -> Option<Response>
Runs before routing. Returning a response short-circuits dispatch.
Sourcefn on_operation(
&self,
_context: &mut HttpRequestContext<'_>,
_operation: &OperationDescriptor,
_security_schemes: &[SecuritySchemeDescriptor],
) -> Option<Response>
fn on_operation( &self, _context: &mut HttpRequestContext<'_>, _operation: &OperationDescriptor, _security_schemes: &[SecuritySchemeDescriptor], ) -> Option<Response>
Runs after routing and before body parsing/handler invocation.
Sourcefn on_response(
&self,
_context: &HttpRequestContext<'_>,
_operation: Option<&OperationDescriptor>,
_response: &mut Response,
)
fn on_response( &self, _context: &HttpRequestContext<'_>, _operation: Option<&OperationDescriptor>, _response: &mut Response, )
Runs in reverse registration order for normal and short-circuit responses.
Sourcefn verifies_security(&self) -> bool
fn verifies_security(&self) -> bool
Returns whether this layer can verify contract security requirements.
Dispatch fails closed when an operation declares a security scheme and
no registered layer can verify it. The default is true so an unknown
layer is assumed capable and never turns the guard into a false 500;
layers that never authenticate should return false so a dispatch path
without a verifier is detected.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".