use poem::{http::StatusCode, Body, IntoResponse}; macro_rules! render { ($template:path) => {{ use $crate::axum_ructe::Render; Render(|o| $template(o)) }}; ($template:path, $($arg:expr),* $(,)*) => {{ use $crate::axum_ructe::Render; Render(move |o| $template(o, $($arg),*)) }} } pub struct Render) -> std::io::Result<()> + Send>(pub T); impl) -> std::io::Result<()> + Send> IntoResponse for Render { fn into_response(self) -> poem::Response { let mut buf = Vec::new(); match self.0(&mut buf) { Ok(()) => Body::from_vec(buf).into_response(), Err(_e) => { // TODO: logging (StatusCode::INTERNAL_SERVER_ERROR, "Render failed").into_response() } } } }