Skip to main content

Middleware

Trait Middleware 

Source
pub trait Middleware<C>:
    Send
    + Sync
    + 'static {
    // Required method
    fn run(&self, ctx: C) -> BoxFuture<'static, Result<C, CrawlError>>;
}
Expand description

Transforms a request context before its matched handler runs.

Required Methods§

Source

fn run(&self, ctx: C) -> BoxFuture<'static, Result<C, CrawlError>>

Runs before the matched handler; receives the context by value and returns it (possibly mutated). An error short-circuits the request.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<C, F, Fut> Middleware<C> for F
where F: Fn(C) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<C, CrawlError>> + Send + 'static,