-
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
Fix IntoResponse
for tuples overriding error response codes
#2468
base: main
Are you sure you want to change the base?
Conversation
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.
Looks decent, but I'm wondering if we should ship this in 0.7.x. It seems pretty likely that some people are relying on IntoResponseParts
from a tuple running even if the final tuple element produces an error (e.g. headers used for distributed tracing).
Also, re. OverrideAllStatusCodes
, could ForceStatusCode
be a better name? It's a bit shorter.
Yeah we probably should wait for 0.8.
👍 |
Do you think we should ship 0.8 soon / start planning for what should be part of it? The |
Yeah I think we should ship sooner rather than later. We'll probably get some hype from being the first major framework to adopt AFIT 😅 although coordinating with matchit would be good. |
@jplatte I've fixed the merge conflicts from |
Fixes #2287
I think 3rd option is the way to go. If we went with option 2 then things like
would have to skip the
IntoResponseParts
in the middle as well asStatusCode::SEE_OTHER
, otherwise we'd get a 500 with alocation
header.However we probably shouldn't skip the
IntoResponseParts
if the first element isn't a status codeThat feels somewhat inconsistent and combined with the fact that it might break middleware that "catch errors" and use tuples to construct new responses I think adding a specific extension to signal "IntoResponse failed" is nicer.
So this PR does just that. It adds
IntoResponseFailed
which if present in response extensions makes other response transformations not run. Thus the 500 status code ofis maintained.
TODO
IntoResponse
andIntoResponseParts
impls and addIntoResponseFailed
where necessary.OverrideAllStatusCodes(StatusCode)
newtype to opt-out and always set the status code.