aboutsummaryrefslogtreecommitdiffstats
path: root/askama_mendes/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--askama_mendes/src/lib.rs19
1 files changed, 6 insertions, 13 deletions
diff --git a/askama_mendes/src/lib.rs b/askama_mendes/src/lib.rs
index baaa49f..d1ccb2c 100644
--- a/askama_mendes/src/lib.rs
+++ b/askama_mendes/src/lib.rs
@@ -2,13 +2,10 @@
#![deny(elided_lifetimes_in_paths)]
#![deny(unreachable_pub)]
-use std::convert::TryFrom;
-
use mendes::application::{Application, Responder};
use mendes::http::header::{HeaderValue, CONTENT_LENGTH, CONTENT_TYPE};
use mendes::http::request::Parts;
use mendes::http::Response;
-use mime_guess::MimeGuess;
pub use askama::*;
@@ -16,7 +13,7 @@ pub fn into_response<A, T>(
app: &A,
req: &Parts,
t: &T,
- ext: Option<&str>,
+ _ext: Option<&str>,
) -> Response<A::ResponseBody>
where
A: Application,
@@ -29,13 +26,9 @@ where
Err(e) => return <A::Error as From<_>>::from(e).into_response(app, req),
};
- let mut builder = Response::builder();
- builder = builder.header(CONTENT_LENGTH, content.len());
- if let Some(ext) = ext {
- if let Some(ty) = MimeGuess::from_ext(ext).first() {
- builder = builder.header(CONTENT_TYPE, HeaderValue::try_from(ty.as_ref()).unwrap());
- }
- }
-
- builder.body(content.into()).unwrap()
+ Response::builder()
+ .header(CONTENT_LENGTH, content.len())
+ .header(CONTENT_TYPE, HeaderValue::from_static(T::MIME_TYPE))
+ .body(content.into())
+ .unwrap()
}