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

pub trait BeforeMiddleware: Send + Sync + 'static {
    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.

Loading content...

Implementations on Foreign Types

impl BeforeMiddleware for Box<dyn BeforeMiddleware>[src]

impl<T> BeforeMiddleware for Arc<T> where
    T: BeforeMiddleware
[src]

Loading content...

Implementors

impl<F> BeforeMiddleware for F where
    F: Send + Sync + 'static + Fn(&mut Request) -> IronResult<()>, 
[src]

Loading content...