Skip to main content

Middleware

Trait Middleware 

Source
pub trait Middleware<C>:
    Send
    + Sync
    + 'static {
    // Required method
    fn handle(
        &self,
        cx: Context<C>,
        next: Next<C>,
    ) -> impl Future<Output = Outcome> + Send;
}
Expand description

Runs around a Worker for every request, see the module.

Required Methods§

Source

fn handle( &self, cx: Context<C>, next: Next<C>, ) -> impl Future<Output = Outcome> + Send

Handles the request in cx, passing it on to next or not.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl<C, F, Fut> Middleware<C> for FromFn<F>
where C: Send + 'static, F: Fn(Context<C>, Next<C>) -> Fut + Send + Sync + 'static, Fut: Future + Send, <Fut as Future>::Output: IntoOutcome,

Source§

impl<C, V> Middleware<C> for Revalidate<V>
where C: Session, V: Validators,

Source§

impl<C> Middleware<C> for SetHeader
where C: Send + 'static,