mirror of
https://github.com/tokio-rs/axum.git
synced 2026-09-08 00:00:24 +02:00
Add IntoResponseParts (#797)
* Add `IntoResponseParts` * docs * Add test * don't allow overriding body or response * macroify impls * re-order things a bit * Fix tests * Also allow overriding version * Move things into separate modules * docs * clean up * fix trybuild test * remove churn * simplify buliding response * fixup test * fix docs typo * Use `HeaderValue::from_static`, might be faster * Bring back `impl IntoResponse` in example * Remove blanket impl to improve error message * don't need to set `content-type` * Apply suggestions from code review Co-authored-by: Jonas Platte <[email protected]> * changelog Co-authored-by: Jonas Platte <[email protected]>
This commit is contained in:
co-authored by
Jonas Platte
parent
da74084146
commit
f12ab072c5
@@ -4,12 +4,11 @@
|
||||
mod de;
|
||||
|
||||
use crate::{
|
||||
body::{boxed, Full},
|
||||
extract::{rejection::*, FromRequest, RequestParts},
|
||||
response::{IntoResponse, Response},
|
||||
routing::{InvalidUtf8InPathParam, UrlParams},
|
||||
};
|
||||
use async_trait::async_trait;
|
||||
use axum_core::response::{IntoResponse, Response};
|
||||
use http::StatusCode;
|
||||
use serde::de::DeserializeOwned;
|
||||
use std::{
|
||||
@@ -382,9 +381,7 @@ impl IntoResponse for FailedToDeserializePathParams {
|
||||
(StatusCode::INTERNAL_SERVER_ERROR, self.0.kind.to_string())
|
||||
}
|
||||
};
|
||||
let mut res = Response::new(boxed(Full::from(body)));
|
||||
*res.status_mut() = status;
|
||||
res
|
||||
(status, body).into_response()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user