Trait AfterMiddleware

Source
pub trait AfterMiddleware:
    Send
    + Sync
    + 'static {
    // Provided methods
    fn after(
        &self,
        _: &mut Request<'_, '_>,
        res: Response,
    ) -> IronResult<Response> { ... }
    fn catch(
        &self,
        _: &mut Request<'_, '_>,
        err: IronError,
    ) -> IronResult<Response> { ... }
}
Expand description

AfterMiddleware are fired after a Handler is called inside of a 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 Chain’s Handler and AfterMiddleware simply do post-processing of that Response, such as adding headers or logging.

Provided Methods§

Source

fn after(&self, _: &mut Request<'_, '_>, res: Response) -> IronResult<Response>

Do whatever post-processing this middleware should do.

Source

fn catch(&self, _: &mut Request<'_, '_>, err: IronError) -> IronResult<Response>

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

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( &self, req: &mut Request<'_, '_>, res: Response, ) -> IronResult<Response>

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

fn catch( &self, req: &mut Request<'_, '_>, err: IronError, ) -> IronResult<Response>

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

Implementations on Foreign Types§

Source§

impl AfterMiddleware for Box<dyn AfterMiddleware>

Source§

fn after( &self, req: &mut Request<'_, '_>, res: Response, ) -> IronResult<Response>

Source§

fn catch( &self, req: &mut Request<'_, '_>, err: IronError, ) -> IronResult<Response>

Source§

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

Source§

fn after( &self, req: &mut Request<'_, '_>, res: Response, ) -> IronResult<Response>

Source§

fn catch( &self, req: &mut Request<'_, '_>, err: IronError, ) -> IronResult<Response>

Implementors§

Source§

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