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

Support running extractors from middleware::from_fn #1088

Merged
merged 2 commits into from Jun 15, 2022

Conversation

davidpdrsn
Copy link
Member

@davidpdrsn davidpdrsn commented Jun 11, 2022

Lately we've had a few people ask about how run extractors from middleware. This was previously possible by building your own RequestParts and then running the extractor. But this adds support to middleware::from_fn to just support extractors directly. I think that is quite clean and doesn't require any new API.

It means if people are writing a middleware by implementing Service themselves then they still have to do it with RequestParts. I don't think thats too bad but we can always consider improving that in the future. I still think this change makes sense on its own though.

Its a breaking change because some type params and bounds changed.

Supersedes #1083

@davidpdrsn davidpdrsn added breaking change A PR that makes a breaking change. A-axum labels Jun 11, 2022
@davidpdrsn davidpdrsn requested a review from jplatte June 11, 2022 19:29
Copy link
Member

@jplatte jplatte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess if we do this for the error-handling layer too, it's fine (and can always be improved upon later).

@davidpdrsn davidpdrsn merged commit 53cce05 into axum-next Jun 15, 2022
@davidpdrsn davidpdrsn deleted the middleware-from-fn-extractors branch June 15, 2022 08:15
@davidpdrsn
Copy link
Member Author

I have no idea what happened to this but the commits weren't in main 🤷 So I've cherry-picked them and verified that the other things merged into axum-next are there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-axum breaking change A PR that makes a breaking change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants