Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove _ext from askama_hyper, too #728

Merged
merged 1 commit into from
Sep 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions askama_derive/src/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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("}")
}
Expand Down
6 changes: 3 additions & 3 deletions askama_hyper/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub use askama::*;
pub use hyper;
use hyper::{header, Body, Response, StatusCode};

pub fn try_respond<T: Template>(t: &T, _ext: &str) -> Result<Response<Body>> {
pub fn try_respond<T: Template>(t: &T) -> Result<Response<Body>> {
Response::builder()
.status(StatusCode::OK)
.header(
Expand All @@ -18,8 +18,8 @@ pub fn try_respond<T: Template>(t: &T, _ext: &str) -> Result<Response<Body>> {
.map_err(|err| Error::Custom(Box::new(err)))
}

pub fn respond<T: Template>(t: &T, _ext: &str) -> Response<Body> {
match try_respond(t, _ext) {
pub fn respond<T: Template>(t: &T) -> Response<Body> {
match try_respond(t) {
Ok(response) => response,
Err(_) => Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
Expand Down