From d3b048544eebf7b8402fb585b4e2531de9b28a33 Mon Sep 17 00:00:00 2001 From: cel 🌸 Date: Wed, 24 Jan 2024 20:23:18 +0000 Subject: Add poem integration --- askama_poem/src/lib.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 askama_poem/src/lib.rs (limited to 'askama_poem/src/lib.rs') diff --git a/askama_poem/src/lib.rs b/askama_poem/src/lib.rs new file mode 100644 index 0000000..de69e09 --- /dev/null +++ b/askama_poem/src/lib.rs @@ -0,0 +1,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: &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(), + } +} -- cgit