From 332d741f212eb2aac7bfb2eec1df1f33bfb46a05 Mon Sep 17 00:00:00 2001 From: René Kijewski Date: Thu, 6 Jan 2022 14:30:46 +0100 Subject: Use Template::MIME_TYPE instead of extension --- askama_rocket/src/lib.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'askama_rocket/src') diff --git a/askama_rocket/src/lib.rs b/askama_rocket/src/lib.rs index 33bd779..f10ba87 100644 --- a/askama_rocket/src/lib.rs +++ b/askama_rocket/src/lib.rs @@ -5,16 +5,15 @@ use std::io::Cursor; pub use askama::*; -use rocket::http::{ContentType, Status}; +use rocket::http::{Header, Status}; pub use rocket::request::Request; use rocket::response::Response; pub use rocket::response::{Responder, Result}; -pub fn respond(t: &T, ext: &str) -> Result<'static> { +pub fn respond(t: &T, _ext: &str) -> Result<'static> { let rsp = t.render().map_err(|_| Status::InternalServerError)?; - let ctype = ContentType::from_extension(ext).ok_or(Status::InternalServerError)?; Response::build() - .header(ctype) + .header(Header::new("content-type", T::MIME_TYPE)) .sized_body(Cursor::new(rsp)) .ok() } -- cgit