Passing values from middleware to handler #1794
-
I would like to implement a middleware that executes every request, checks for authentication, and delivers authentication information to routers. It's like app_data is passed as a parameter of the router. example
I could send it as app_data, but I think App::app_datas or App::data are global values, not generated per request. So there seems to be a problem to apply. Is this the best? Or is there a better way? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
https://docs.rs/actix-web/3.2.0/actix_web/trait.HttpMessage.html#tymethod.extensions_mut Use this method to gain mutable access to request's extension. |
Beta Was this translation helpful? Give feedback.
-
thank you |
Beta Was this translation helpful? Give feedback.
https://docs.rs/actix-web/3.2.0/actix_web/trait.HttpMessage.html#tymethod.extensions_mut
Use this method to gain mutable access to request's extension.