aboutsummaryrefslogblamecommitdiffstats
path: root/askama_rocket/src/lib.rs
blob: f10ba871d9d219ddb0f999fee5c50cc3426c67ca (plain) (tree)
1
2
3
4
5
6
7
8
                       
                                   
                         
 


                    
                                   



                                              
                                                                   
                                                                   
                     
                                                          
                                     

             
#![forbid(unsafe_code)]
#![deny(elided_lifetimes_in_paths)]
#![deny(unreachable_pub)]

use std::io::Cursor;

pub use askama::*;
use rocket::http::{Header, Status};
pub use rocket::request::Request;
use rocket::response::Response;
pub use rocket::response::{Responder, Result};

pub fn respond<T: Template>(t: &T, _ext: &str) -> Result<'static> {
    let rsp = t.render().map_err(|_| Status::InternalServerError)?;
    Response::build()
        .header(Header::new("content-type", T::MIME_TYPE))
        .sized_body(Cursor::new(rsp))
        .ok()
}