-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 middleware::from_extractor_with_state
#1373
Comments
@davidpdrsn the question was about |
Ah sorry my bad. Yes that makes sense to have! Although using extractors is easy in |
middleware::from_extractor_with_state
Hi, thanks for the responses!
Yeah, that's the tricky part. 🙂 I'm actually using a middleware as "glue code" right now to get the application running. I'd like to have a go at submitting a PR myself for that, but I have other priorities for the coming weeks and can't say for certain that I'll find the time for it. I have a rough idea how I'd go about it but I'm not sure how involved the changes would actually become. |
It should be very similar to #1342 |
Bug Report
Version
Platform
Linux hostname 5.19.8-100.fc35.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Sep 8 19:23:03 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Description
Hi! I've been happily using Axum on a small server prototype and started migrating to v0.6.0 because the state feature looks very convenient for simplifying the application code. However, I've encountered an issue I can't explain on my own.
I'm defining an extractor that requires state via a
FromRef<S>
trait bound as described in https://docs.rs/axum/0.6.0-rc.2/axum/extract/struct.State.html#for-library-authors and try to use it as a middleware withmiddleware::from_extractor
directly on a handler. I'd expected this to work and found no information to the contrary in the documentation on state and extractors. Instead it fails with an error at compile time. I'm not sure whether this is a bug or if I'm using Axum in an unintended way.Minimal Example that produces the unexpected behavior:
The compiler error is as follows:
Thanks in advance, I'd be happy to provide more details if necessary. 🙂
The text was updated successfully, but these errors were encountered: