mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-29 00:00:18 +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
@@ -6,7 +6,6 @@
|
||||
|
||||
use askama::Template;
|
||||
use axum::{
|
||||
body::{self, Full},
|
||||
extract,
|
||||
http::StatusCode,
|
||||
response::{Html, IntoResponse, Response},
|
||||
@@ -55,13 +54,11 @@ where
|
||||
fn into_response(self) -> Response {
|
||||
match self.0.render() {
|
||||
Ok(html) => Html(html).into_response(),
|
||||
Err(err) => Response::builder()
|
||||
.status(StatusCode::INTERNAL_SERVER_ERROR)
|
||||
.body(body::boxed(Full::from(format!(
|
||||
"Failed to render template. Error: {}",
|
||||
err
|
||||
))))
|
||||
.unwrap(),
|
||||
Err(err) => (
|
||||
StatusCode::INTERNAL_SERVER_ERROR,
|
||||
format!("Failed to render template. Error: {}", err),
|
||||
)
|
||||
.into_response(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user