pub trait Middleware<T>: Send + Sync {
// Required method
fn process<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
state: &'life1 mut RequestState<T>,
payload: &'life2 Bytes,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
}Expand description
Middleware trait
Middlewares can inspect and modify request state before handlers execute. They can also short-circuit the request by returning an error.
Required Methods§
Sourcefn process<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
state: &'life1 mut RequestState<T>,
payload: &'life2 Bytes,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn process<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
state: &'life1 mut RequestState<T>,
payload: &'life2 Bytes,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Process the request state before the handler executes
Return Ok(()) to continue to the next middleware/handler. Return Err(_) to short-circuit and return an error response.