aboutsummaryrefslogtreecommitdiffstats
path: root/askama_poem/src/lib.rs
blob: de69e09647aecac99863decf5875175aafa05903 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#![forbid(unsafe_code)]
#![deny(elided_lifetimes_in_paths)]
#![deny(unreachable_pub)]

pub use askama::*;
use poem::http::StatusCode;
pub use poem::{web::IntoResponse, Response};

pub fn into_response<T: Template>(t: &T) -> Response {
    match t.render() {
        Ok(body) => Response::builder()
            .status(StatusCode::OK)
            .content_type(T::MIME_TYPE)
            .body(body),
        Err(_) => StatusCode::INTERNAL_SERVER_ERROR.into(),
    }
}