Middleware

Trait Middleware 

Source
pub trait Middleware: Send + Sync {
    // Required method
    fn handle<'life0, 'life1, 'async_trait>(
        &'life0 self,
        ctx: &'life1 mut Context,
        next: Next,
    ) -> Pin<Box<dyn Future<Output = Result> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided method
    fn name(&self) -> &str { ... }
}
Expand description

Middleware that wraps around the remaining middleware chain.

Required Methods§

Source

fn handle<'life0, 'life1, 'async_trait>( &'life0 self, ctx: &'life1 mut Context, next: Next, ) -> Pin<Box<dyn Future<Output = Result> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Asynchronously handle the request, and return a response.

Provided Methods§

Source

fn name(&self) -> &str

Set the middleware’s name. By default it uses the type signature.

Trait Implementations§

Source§

impl Debug for dyn Middleware

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Implementors§

Source§

impl<F> Middleware for F
where F: for<'arg1> Fn1<&'arg1 mut Context, Next> + Sync + Send, for<'arg1> <F as Fn1<&'arg1 mut Context, Next>>::Output: Future<Output = Result> + Send,