-
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
Implement IntoResponse
for Response<()>
and response::Parts
#950
Implement IntoResponse
for Response<()>
and response::Parts
#950
Conversation
I think the
I think the |
Hm an issue with this is that we cannot merge two Maybe we should re-open hyperium/http#525? |
Yep. The I can see One potential alternative for that is to impl this for |
I think this looks good as is but I don't think we should merge it until hyperium/http#546 has landed. |
1 similar comment
This comment was marked as duplicate.
This comment was marked as duplicate.
http::response
typesIntoResponse
for Response<()>
and response::Parts
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 good to go now :)
What about extra impls for |
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.
Changes look good either way.
Good idea! I filed #979. I'll look into it. |
Add a simple implementation to use
Parts
andResponse<()>
as a source forIntoResponse
.This doesn't fit neatly into the
IntoResponseParts
paradigm becauseParts
already contains a status code. The implementation itself is rather trivial.Motivation
I have a library where I generate some generic template responses using
http::response::Builder
and wanted to be able to make it one step easier to use those templates (often built with a body of()
, and then substituted with the intended body) as responses. This makes it so that the template can be built and specified next to the body to be placed into the response.Solution
Add impls for
Parts
andResponse<()>
. The newResponse<()>
impl discards the existing()
body and uses the provided body to construct the response and then moves the headers and status into the new response.