Trait AfterMiddleware

Source
pub trait AfterMiddleware:
    Send
    + Sync
    + 'static {
    // Provided methods
    fn after<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _: &'life1 mut Request,
        res: Response,
    ) -> Pin<Box<dyn Future<Output = Result<Response>> + 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<Response>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

AfterMiddleware are fired after a Handler is called inside of the Middlewares chain.

AfterMiddleware receive both a Request and a Response and are responsible for doing any response post-processing.

AfterMiddleware should not overwrite the contents of a Response. In the common case, a complete response is generated by the Middlewares’s Handler and AfterMiddleware simply do post-processing of that Response, such as adding headers or logging.

Provided Methods§

Source

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

Do whatever post-processing this middleware should do.

Source

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

Respond to an error thrown by previous AfterMiddleware or the Handler.

Returning Ok will cause the request to resume the normal flow at the next AfterMiddleware.

Trait Implementations§

Source§

impl AfterMiddleware for Box<dyn AfterMiddleware>

Source§

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

Do whatever post-processing this middleware should do.
Source§

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

Respond to an error thrown by previous AfterMiddleware or the Handler. Read more

Implementations on Foreign Types§

Source§

impl AfterMiddleware for Box<dyn AfterMiddleware>

Source§

fn after<'life0, 'life1, 'async_trait>( &'life0 self, req: &'life1 mut Request, res: Response, ) -> Pin<Box<dyn Future<Output = Result<Response>> + 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<Response>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

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

Source§

fn after<'life0, 'life1, 'async_trait>( &'life0 self, req: &'life1 mut Request, res: Response, ) -> Pin<Box<dyn Future<Output = Result<Response>> + 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<Response>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Implementors§

Source§

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