pub trait MiddlewareContract: ConcreteMiddleware {
// Required method
fn handle<'life0, 'async_trait>(
&'life0 self,
request: Request,
next: Next,
) -> Pin<Box<dyn Future<Output = Response> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
// Provided method
fn name(&self) -> &'static str { ... }
}Expand description
A stage in the request pipeline.
Required Methods§
Sourcefn handle<'life0, 'async_trait>(
&'life0 self,
request: Request,
next: Next,
) -> Pin<Box<dyn Future<Output = Response> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn handle<'life0, 'async_trait>(
&'life0 self,
request: Request,
next: Next,
) -> Pin<Box<dyn Future<Output = Response> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Handle the request, optionally calling next.
Returning without calling next.run(..) short-circuits the pipeline —
the handler and every later middleware are skipped. That is how
authentication, rate limiting and CORS preflight all work.
Provided Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".