mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-14 00:00:15 +02:00
Support returning any http_body::Body from IntoResponse (#86)
Adds associated `Body` and `BodyError` types to `IntoResponse`. This is required for returning responses with bodies other than `hyper::Body` from handlers. That wasn't previously possible. This is a breaking change so should be shipped in 0.2.
This commit is contained in:
+4
-3
@@ -268,8 +268,9 @@ macro_rules! impl_handler {
|
||||
Fut: Future<Output = Res> + Send,
|
||||
B: Send + 'static,
|
||||
Res: IntoResponse,
|
||||
B: Send + 'static,
|
||||
$head: FromRequest<B> + Send,
|
||||
$( $tail: FromRequest<B> + Send, )*
|
||||
$( $tail: FromRequest<B> + Send,)*
|
||||
{
|
||||
type Sealed = sealed::Hidden;
|
||||
|
||||
@@ -278,13 +279,13 @@ macro_rules! impl_handler {
|
||||
|
||||
let $head = match $head::from_request(&mut req).await {
|
||||
Ok(value) => value,
|
||||
Err(rejection) => return rejection.into_response().map(crate::body::box_body),
|
||||
Err(rejection) => return rejection.into_response().map(box_body),
|
||||
};
|
||||
|
||||
$(
|
||||
let $tail = match $tail::from_request(&mut req).await {
|
||||
Ok(value) => value,
|
||||
Err(rejection) => return rejection.into_response().map(crate::body::box_body),
|
||||
Err(rejection) => return rejection.into_response().map(box_body),
|
||||
};
|
||||
)*
|
||||
|
||||
|
||||
Reference in New Issue
Block a user