-
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
Introduce Response
type alias as a shorthand for Response<BoxBody>
#590
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.
Haven't reviewed all of the changes, but from the PR description this sounds good to me!
I think the ergonomics gained from this are nice but I have two concerns:
Personally I think we should wait with this and see what happens in hyper/http-body over the next 6 months or so. We could also only add this to axum and not axum-core. I think I'd be more open to that. However this might not matter in the long run because a 1.0 of hyper would probably also mean a 1.0 of http, which would probably include breaking changes that would propagate to axum-core 🤷 |
In my personal project I end up using it quite a lot, because it's more convenient for callers (and equally easy to implement if there are branches) if a function returns
I will do that.
I don't think so, because Axum places a much greater focus on generic request bodies. It might be best if the situation around request bodies is left to evolve separately after we see where Hyper goes.
I decided against this because:
|
I also kinda realized that while I wrote my reply so because of that I think it makes sense! |
Thanks! |
Motivation
Nowadays
Response
is pretty much only used withBoxBody
as its body type, but it becomes tedious to type outResponse<BoxBody>
every time and have to import them both.Solution
Provide a new type alias to allow writing
Response
instead of the fullResponse<BoxBody>
:This type is defined in
axum_core::response
but is re-exported inaxum
,axum_core
,axum::response
andaxum_core::response
axum::response
. The "default type parameter" trick is used to not lose any functionality overhttp::Response
.Prior art: Warp does this.