pub trait BeforeMiddleware: Send + Sync + 'static {
    // Provided methods
    fn before<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _: &'life1 mut Request
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn catch<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _: &'life1 mut Request,
        err: Error
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

BeforeMiddleware are fired before a Handler is called inside of a Chain.

BeforeMiddleware are responsible for doing request pre-processing that requires the ability to change control-flow, such as authorization middleware, or for editing the request by modifying the headers.

BeforeMiddleware only have access to the Request, if you need to modify or read a Response, you will need AfterMiddleware. Middleware which wishes to send an early response that is not an error cannot be BeforeMiddleware, but should instead be AroundMiddleware.

Provided Methods§

source

fn before<'life0, 'life1, 'async_trait>( &'life0 self, _: &'life1 mut Request ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Do whatever work this middleware should do with a Request object.

source

fn catch<'life0, 'life1, 'async_trait>( &'life0 self, _: &'life1 mut Request, err: Error ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Respond to an error thrown by a previous BeforeMiddleware.

Returning a Ok will cause the request to resume the normal flow at the next BeforeMiddleware, or if this was the last BeforeMiddleware, at the Handler.

Trait Implementations§

source§

impl BeforeMiddleware for Box<dyn BeforeMiddleware>

source§

fn before<'life0, 'life1, 'async_trait>( &'life0 self, req: &'life1 mut Request ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Do whatever work this middleware should do with a Request object.
source§

fn catch<'life0, 'life1, 'async_trait>( &'life0 self, req: &'life1 mut Request, err: Error ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Respond to an error thrown by a previous BeforeMiddleware. Read more

Implementations on Foreign Types§

source§

impl BeforeMiddleware for Box<dyn BeforeMiddleware>

source§

fn before<'life0, 'life1, 'async_trait>( &'life0 self, req: &'life1 mut Request ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

source§

fn catch<'life0, 'life1, 'async_trait>( &'life0 self, req: &'life1 mut Request, err: Error ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

source§

impl<T> BeforeMiddleware for Arc<T>where T: BeforeMiddleware,

source§

fn before<'life0, 'life1, 'async_trait>( &'life0 self, req: &'life1 mut Request ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

source§

fn catch<'life0, 'life1, 'async_trait>( &'life0 self, req: &'life1 mut Request, err: Error ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Implementors§

source§

impl<F> BeforeMiddleware for Fwhere F: Send + Sync + 'static + Fn(&mut Request) -> Result<()>,