Trait Middleware

Source
pub trait Middleware:
    Send
    + Sync
    + 'static {
    // Required method
    fn call(
        &self,
        req: Request,
        next: Box<dyn Fn(Request) -> Pin<Box<dyn Future<Output = Response> + Send + 'static>> + Send + Sync>,
    ) -> Pin<Box<dyn Future<Output = Response> + Send + 'static>>;
}
Expand description

Middleware can intercept requests before they reach your handlers

Required Methods§

Source

fn call( &self, req: Request, next: Box<dyn Fn(Request) -> Pin<Box<dyn Future<Output = Response> + Send + 'static>> + Send + Sync>, ) -> Pin<Box<dyn Future<Output = Response> + Send + 'static>>

Do your thing with the request, then decide whether to continue the chain

Implementors§