pub trait BeforeMiddleware:
Send
+ Sync
+ 'static {
// Provided methods
fn before<'life0, 'life1, 'async_trait>(
&'life0 self,
_: &'life1 mut Request,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn catch<'life0, 'life1, 'async_trait>(
&'life0 self,
_: &'life1 mut Request,
err: Error,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}Expand description
BeforeMiddleware are fired before a Handler is called inside of a Middlewares.
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§
Sourcefn before<'life0, 'life1, 'async_trait>(
&'life0 self,
_: &'life1 mut Request,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn before<'life0, 'life1, 'async_trait>(
&'life0 self,
_: &'life1 mut Request,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Do whatever work this middleware should do with a Request object.
Sourcefn catch<'life0, 'life1, 'async_trait>(
&'life0 self,
_: &'life1 mut Request,
err: Error,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn catch<'life0, 'life1, 'async_trait>(
&'life0 self,
_: &'life1 mut Request,
err: Error,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
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.
Trait Implementations§
Source§impl BeforeMiddleware for Box<dyn BeforeMiddleware>
impl BeforeMiddleware for Box<dyn BeforeMiddleware>
Source§fn before<'life0, 'life1, 'async_trait>(
&'life0 self,
req: &'life1 mut Request,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn before<'life0, 'life1, 'async_trait>(
&'life0 self,
req: &'life1 mut Request,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Request object.Source§fn catch<'life0, 'life1, 'async_trait>(
&'life0 self,
req: &'life1 mut Request,
err: Error,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn catch<'life0, 'life1, 'async_trait>(
&'life0 self,
req: &'life1 mut Request,
err: Error,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
BeforeMiddleware. Read more