Remove the associated Body type on IntoResponse (#571)

This commit is contained in:
Kai Jewson
2021-11-28 18:52:18 +01:00
committed by GitHub
parent decdd4c948
commit 2b6dba49cb
25 changed files with 171 additions and 358 deletions
+5 -8
View File
@@ -6,14 +6,14 @@
use askama::Template;
use axum::{
body::{Bytes, Full},
body::{self, BoxBody, Full},
extract,
http::{Response, StatusCode},
response::{Html, IntoResponse},
routing::get,
Router,
};
use std::{convert::Infallible, net::SocketAddr};
use std::net::SocketAddr;
#[tokio::main]
async fn main() {
@@ -52,18 +52,15 @@ impl<T> IntoResponse for HtmlTemplate<T>
where
T: Template,
{
type Body = Full<Bytes>;
type BodyError = Infallible;
fn into_response(self) -> Response<Self::Body> {
fn into_response(self) -> Response<BoxBody> {
match self.0.render() {
Ok(html) => Html(html).into_response(),
Err(err) => Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Full::from(format!(
.body(body::boxed(Full::from(format!(
"Failed to render template. Error: {}",
err
)))
))))
.unwrap(),
}
}