Skip to main content

Middleware

Trait Middleware 

Source
pub trait Middleware: Send + Sync {
    // Required method
    fn process(
        &self,
        request: &mut Request,
        next: &dyn RequestHandler,
    ) -> Result<Response, HttpError>;
}
Expand description

Layer that may inspect or mutate the request, then call next.

Required Methods§

Source

fn process( &self, request: &mut Request, next: &dyn RequestHandler, ) -> Result<Response, HttpError>

Runs this layer.

§Errors

Returns HttpError instead of calling next, or when next fails.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§