-
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 trait IntoResponseHeaders #649
Conversation
Due to the new blanket impl of |
d431567
to
e0ee388
Compare
7bac03b
to
b9e4c5e
Compare
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.
I think this is looking really good! Getting these more or less duplicate impls combined into is a big win imo!
If you rebase/merge latest axum-next
I'll do a more detailed review, unless there are more things you wanna fix first.
e0ee388
to
6b5d3b2
Compare
I think it makes sense to deal with the proposed This one is useful as-is. |
6b5d3b2
to
f684eee
Compare
f04cf94
to
a7de04f
Compare
Sorry for taking so long to review this. Hoping to get to it this weekend. |
… and update IntoResponse impls that use HeaderMap to be generic instead.
… and remove IntoResponse impls that use it.
f684eee
to
520c42d
Compare
Rebased. |
* Introduce IntoResponseHeaders trait * Implement IntoResponseHeaders for HeaderMap * Add impl IntoResponse for impl IntoResponseHeaders … and update IntoResponse impls that use HeaderMap to be generic instead. * Add impl IntoResponseHeaders for Headers … and remove IntoResponse impls that use it. * axum-debug: Fix grammar in docs * Explain confusing error message in docs
* Introduce IntoResponseHeaders trait * Implement IntoResponseHeaders for HeaderMap * Add impl IntoResponse for impl IntoResponseHeaders … and update IntoResponse impls that use HeaderMap to be generic instead. * Add impl IntoResponseHeaders for Headers … and remove IntoResponse impls that use it. * axum-debug: Fix grammar in docs * Explain confusing error message in docs
* Introduce IntoResponseHeaders trait * Implement IntoResponseHeaders for HeaderMap * Add impl IntoResponse for impl IntoResponseHeaders … and update IntoResponse impls that use HeaderMap to be generic instead. * Add impl IntoResponseHeaders for Headers … and remove IntoResponse impls that use it. * axum-debug: Fix grammar in docs * Explain confusing error message in docs
Motivation
It would be nice to be able to return
TypedHeader
in the same positions asHeaders<_>
, but that doesn't work without moving it intoaxum-core
due to coherence and that would be very unfortunate. Also,Headers
only lives inaxum-core
due to the same coherence issues.Solution
Introduce a new trait
IntoResponseHeaders
and implement it forHeaderMap
andHeaders
. MoveHeaders
into axum.Notes
I think this is all of the hard stuff dealt with. It should now be straight-forward to
move(done), implementHeaders
into axumIntoResponseHeaders
forTypedHeader
and move it into its own module (outsideresponse
) / re-export it from theaxum
crate root likeJson
and addIntoResponse
impls for tuples with moreIntoResponseHeaders
items.