Trait hyper_middleware::middleware::BeforeMiddleware
source · pub trait BeforeMiddleware: Send + Sync + 'static {
fn before(&self, _: &mut Request) -> Result<()> { ... }
fn catch(&self, _: &mut Request, err: Error) -> Result<()> { ... }
}
Expand description
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
.