About Middleware #155
josejachuf
started this conversation in
General
Replies: 1 comment 1 reply
-
When router matched, handlers will collected in a Vec. #[async_trait]
impl Handler for Middleware {
async fn handle(&self, req: &mut Request, depot: &mut Depot, res: &mut Response, ctrl: &mut FlowCtrl) {
ctrl.call_next(req, depot, res).await;
}
}
async fn handle(&self, req: &mut Request, depot: &mut Depot, res: &mut Response, ctrl: &mut FlowCtrl) {
// Write your logic code here
ctrl.call_next(req, depot, res).await;
} https://github.com/salvo-rs/salvo/blob/main/extra/src/size_limiter.rs Or after handler: async fn handle(&self, req: &mut Request, depot: &mut Depot, res: &mut Response, ctrl: &mut FlowCtrl) {
ctrl.call_next(req, depot, res).await;
// Write your logic code here
} https://github.com/salvo-rs/salvo/blob/main/extra/src/compression.rs |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi
With the Middleware can something similar to this [1] be achieved?
It can be manipulated before and after the handler
Jose
[1] https://emmett.sh/docs/2.4.x/pipeline
Beta Was this translation helpful? Give feedback.
All reactions