[−][src]Trait iron::middleware::BeforeMiddleware
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
.
Implementations on Foreign Types
impl BeforeMiddleware for Box<dyn BeforeMiddleware>
[src]
fn before(&self, req: &mut Request) -> IronResult<()>
[src]
fn catch(&self, req: &mut Request, err: IronError) -> IronResult<()>
[src]
impl<T> BeforeMiddleware for Arc<T> where
T: BeforeMiddleware,
[src]
T: BeforeMiddleware,
fn before(&self, req: &mut Request) -> IronResult<()>
[src]
fn catch(&self, req: &mut Request, err: IronError) -> IronResult<()>
[src]
Implementors
impl<F> BeforeMiddleware for F where
F: Send + Sync + 'static + Fn(&mut Request) -> IronResult<()>,
[src]
F: Send + Sync + 'static + Fn(&mut Request) -> IronResult<()>,