pub trait AfterMiddleware:
Send
+ Sync
+ 'static {
// Provided methods
fn after<'life0, 'life1, 'async_trait>(
&'life0 self,
_: &'life1 mut Request,
res: Response,
) -> Pin<Box<dyn Future<Output = Result<Response>> + 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<Response>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}
Expand description
AfterMiddleware
are fired after a Handler
is called inside of the Middlewares
chain.
AfterMiddleware
receive both a Request
and a Response
and are responsible for doing
any response post-processing.
AfterMiddleware
should not overwrite the contents of a Response
. In
the common case, a complete response is generated by the Middlewares’s Handler
and
AfterMiddleware
simply do post-processing of that Response, such as
adding headers or logging.
Provided Methods§
Sourcefn after<'life0, 'life1, 'async_trait>(
&'life0 self,
_: &'life1 mut Request,
res: Response,
) -> Pin<Box<dyn Future<Output = Result<Response>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn after<'life0, 'life1, 'async_trait>(
&'life0 self,
_: &'life1 mut Request,
res: Response,
) -> Pin<Box<dyn Future<Output = Result<Response>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Do whatever post-processing this middleware should do.
Sourcefn catch<'life0, 'life1, 'async_trait>(
&'life0 self,
_: &'life1 mut Request,
err: Error,
) -> Pin<Box<dyn Future<Output = Result<Response>> + 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<Response>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Respond to an error thrown by previous AfterMiddleware
or the Handler
.
Returning Ok
will cause the request to resume the normal flow at the
next AfterMiddleware
.
Trait Implementations§
Source§impl AfterMiddleware for Box<dyn AfterMiddleware>
impl AfterMiddleware for Box<dyn AfterMiddleware>
Source§fn after<'life0, 'life1, 'async_trait>(
&'life0 self,
req: &'life1 mut Request,
res: Response,
) -> Pin<Box<dyn Future<Output = Result<Response>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn after<'life0, 'life1, 'async_trait>(
&'life0 self,
req: &'life1 mut Request,
res: Response,
) -> Pin<Box<dyn Future<Output = Result<Response>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Do whatever post-processing this middleware should do.