Trait iron::middleware::BeforeMiddleware [] [src]

pub trait BeforeMiddleware: Send + Sync + Any {
    fn before(&self, _: &mut Request) -> IronResult<()> { ... }
    fn catch(&self, _: &mut Request, err: IronError) -> IronResult<()> { ... }
}

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

fn before(&self, _: &mut Request) -> IronResult<()>

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

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

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.

Implementors