diff --git a/askama_derive/src/generator.rs b/askama_derive/src/generator.rs index 48a3798bc..08c1de168 100644 --- a/askama_derive/src/generator.rs +++ b/askama_derive/src/generator.rs @@ -445,8 +445,7 @@ impl<'a> Generator<'a> { "{} {{", quote!(fn from(value: &#ident #orig_ty_generics) -> Self) ))?; - let ext = self.input.extension().unwrap_or("txt"); - buf.writeln(&format!("::askama_hyper::respond(value, {:?})", ext))?; + buf.writeln("::askama_hyper::respond(value)")?; buf.writeln("}")?; buf.writeln("}") } diff --git a/askama_hyper/src/lib.rs b/askama_hyper/src/lib.rs index 07ede8861..5032da276 100644 --- a/askama_hyper/src/lib.rs +++ b/askama_hyper/src/lib.rs @@ -7,7 +7,7 @@ pub use askama::*; pub use hyper; use hyper::{header, Body, Response, StatusCode}; -pub fn try_respond(t: &T, _ext: &str) -> Result> { +pub fn try_respond(t: &T) -> Result> { Response::builder() .status(StatusCode::OK) .header( @@ -18,8 +18,8 @@ pub fn try_respond(t: &T, _ext: &str) -> Result> { .map_err(|err| Error::Custom(Box::new(err))) } -pub fn respond(t: &T, _ext: &str) -> Response { - match try_respond(t, _ext) { +pub fn respond(t: &T) -> Response { + match try_respond(t) { Ok(response) => response, Err(_) => Response::builder() .status(StatusCode::INTERNAL_SERVER_ERROR)