pub trait Middleware: Send + Sync {
// Required method
fn handle<'life0, 'async_trait>(
&'life0 self,
request: Request,
next: Next,
) -> Pin<Box<dyn Future<Output = Result<Response>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
Middleware trait for processing HTTP requests and responses
Required Methods§
Sourcefn handle<'life0, 'async_trait>(
&'life0 self,
request: Request,
next: Next,
) -> Pin<Box<dyn Future<Output = Result<Response>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn handle<'life0, 'async_trait>(
&'life0 self,
request: Request,
next: Next,
) -> Pin<Box<dyn Future<Output = Result<Response>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Process the request and response
The middleware can:
- Inspect or modify the request
- Short-circuit by returning early
- Call
next.run(request).awaitto continue the chain