Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add example showing how to access shared state from middleware in 1.0.0-alpha.6 #113

Closed
ctsrc opened this issue Apr 15, 2019 · 1 comment

Comments

@ctsrc
Copy link

ctsrc commented Apr 15, 2019

Accessing shared state in handlers is demonstrated in https://github.com/actix/examples/blob/815e34f32ded77f73145fb0373a060b22636f689/state/src/main.rs

And with the way middleware worked previously, you could access shared state in the middleware as such: https://stackoverflow.com/questions/50428385/application-state-access-from-an-actix-web-application-middleware/50428541#50428541

But with the way middleware works now, as demonstrated in https://github.com/actix/examples/blob/09b0188ff99e872898793bd815382a4105219b77/middleware/src/redirect.rs. it is not apparent how one would access shared state from middleware.

Adding an example showing how to access shared state from middleware in 1.0.0-alpha.6 would be immensly helpful.

@ctsrc
Copy link
Author

ctsrc commented Apr 15, 2019

Got an answer to this on Reddit from one of the people involved with actix. It's quite simple so no example for this is needed after all I think.

https://docs.rs/actix-web/1.0.0-alpha.6/actix_web/dev/struct.ServiceRequest.html#method.app_data

@ctsrc ctsrc closed this as completed Apr 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant