Skip to main content

Middleware

Trait Middleware 

Source
pub trait Middleware: Send + Sync {
    // Required methods
    fn process<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        ctx: &'life1 mut RequestContext,
        next: &'life2 dyn Next,
    ) -> Pin<Box<dyn Future<Output = Result<Response>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn name(&self) -> &str;

    // Provided method
    fn order(&self) -> i32 { ... }
}
Expand description

Trait implemented by each middleware layer.

Required Methods§

Source

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

Process the request. Call next.run(ctx) to continue the pipeline.

Source

fn name(&self) -> &str

Human-readable name of this middleware.

Provided Methods§

Source

fn order(&self) -> i32

Execution order — lower values run first.

Implementors§