-
Notifications
You must be signed in to change notification settings - Fork 649
Move router error handling into new middleware layer #3373
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
Conversation
The outer R404 will catch any routing errors, so it is unnecessary here.
Other error conversions in `AppError::try_convert()` cannot be moved because endpoint logic relys on being able to detect these (converted) errors. Errors that endpoints don't care about (or cannot detect), can be converted to user-friendly errors in middleware.
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.
LGTM
one small comment, but feel free to r=me
src/router.rs
Outdated
body, | ||
Body::Owned(vec) if vec == br#"{"errors":[{"detail":"Not Found"}]}"# | ||
)); | ||
} |
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.
would it make sense to convert that to a more high-level API test?
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.
This particular test moved to the middleware. We could do something under tests/all.rs
as well. The main difference would be that it would load other middleware layers as well.
@bors r=Turbo87 |
📌 Commit ff1f7cc has been approved by |
☀️ Test successful - checks-actions |
This moves handling of routing errors into middleware and adds a test for the conversion.
Additionally we previously called
router.recognize()
instead ofrouter.call()
. By switching we can let theconduit-router
logic handle addingParams
to the request extensions.A potential allocation is removed from json error handling, although the compiler may be able to eliminate that allocation already.
r? @Turbo87