aboutsummaryrefslogtreecommitdiffstats
path: root/askama_poem/src/lib.rs
diff options
context:
space:
mode:
authorLibravatar cel 🌸 <cel@blos.sm>2024-01-24 20:23:18 +0000
committerLibravatar cel 🌸 <cel@blos.sm>2024-01-24 20:23:18 +0000
commitd3b048544eebf7b8402fb585b4e2531de9b28a33 (patch)
tree2e697063854d22aff603ba3691c6453ddf5cd87b /askama_poem/src/lib.rs
parentef53238ae2ee77becc44bcb0b77c1c4daceca5af (diff)
downloadaskama-main.tar.gz
askama-main.tar.bz2
askama-main.zip
Add poem integrationHEADmain
Diffstat (limited to 'askama_poem/src/lib.rs')
-rw-r--r--askama_poem/src/lib.rs17
1 files changed, 17 insertions, 0 deletions
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: 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(),
+ }
+}