[][src]Trait amiya::middleware::Middleware

pub trait Middleware<Ex>: Send + Sync {
#[must_use]    fn handle<'life0, 'life1, 'async_trait>(
        &'life0 self,
        ctx: Context<'life1, Ex>
    ) -> Pin<Box<dyn Future<Output = Result> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
; }

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

#[must_use]fn handle<'life0, 'life1, 'async_trait>(
    &'life0 self,
    ctx: Context<'life1, Ex>
) -> Pin<Box<dyn Future<Output = Result> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 

You middleware's handler function, it will be called when request reach this middleware

Loading content...

Implementors

impl<Ex> Middleware<Ex> for M<Ex> where
    Ex: Send + Sync + 'static, 
[src]

impl<Ex> Middleware<Ex> for MethodRouter<Ex> where
    Ex: Send + Sync + 'static, 
[src]

impl<Ex> Middleware<Ex> for Router<Ex> where
    Ex: Send + Sync + 'static, 
[src]

impl<Ex: Send + Sync + 'static> Middleware<Ex> for Amiya<Ex>[src]

Loading content...