-
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
Support chaining handlers with one.or(two).or(three)
#1170
Conversation
one.or(two).or(three)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An interesting experiment, but I feel like to be robust, this would have to consider some extractors rejecting the request as fatal, while others trigger the .or
fallback. That is, I would in most cases only want fallback for Path
mismatches, not Query
and certainly not extractors like Extension
that are often not at all related to user input.
Also I'm having somewhat of a hard time reviewing the code. Docs are looking good though.
if there is a fallback, when to trigger fallback? all of them rejected? |
If an extractor rejects the fallback is called. Cannot call the handler if the extractor doesn't succeed because we don't have a value of the right type. So we must call the next handler in the |
Hm, maybe we should also have |
This is something I've playing around with which I think we should explore in axum-extra. It enables doing handler fallbacks like this:
So if
one
rejects thentwo
runs and finallythree
.This is something users have asked about for but our current best solution is "do it manually in a single handler". That is quite tedious especially if you want to run different extractors for each handler.