pub trait Middleware<Ex>: Send + Sync {
// Required method
fn handle<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: Context<'life1, Ex>,
) -> Pin<Box<dyn Future<Output = Result> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}
Expand description
Use your custom type as a middleware by implement this trait.
You need async_trait
to implement this.
See examples/measurer.rs
for a example of process time usage measurer middleware.
Required Methods§
Sourcefn handle<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: Context<'life1, Ex>,
) -> Pin<Box<dyn Future<Output = Result> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn handle<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: Context<'life1, Ex>,
) -> Pin<Box<dyn Future<Output = Result> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Your middleware handler function, it will be called when request reach this middleware