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_derive/src/generator.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'askama_derive/src') diff --git a/askama_derive/src/generator.rs b/askama_derive/src/generator.rs index 22f996f..1a2537e 100644 --- a/askama_derive/src/generator.rs +++ b/askama_derive/src/generator.rs @@ -74,6 +74,8 @@ impl<'a> Generator<'a> { self.impl_hyper_into_response(&mut buf)?; #[cfg(feature = "with-mendes")] self.impl_mendes_responder(&mut buf)?; + #[cfg(feature = "with-poem")] + self.impl_poem_into_response(&mut buf)?; #[cfg(feature = "with-rocket")] self.impl_rocket_responder(&mut buf)?; #[cfg(feature = "with-tide")] @@ -284,6 +286,20 @@ impl<'a> Generator<'a> { Ok(()) } + // Implement Poem's `IntoResponse`. + #[cfg(feature = "with-poem")] + fn impl_poem_into_response(&mut self, buf: &mut Buffer) -> Result<(), CompileError> { + self.write_header(buf, "::askama_poem::IntoResponse", None)?; + buf.writeln("#[inline]")?; + buf.writeln( + "fn into_response(self)\ + -> ::askama_poem::Response {", + )?; + buf.writeln("::askama_poem::into_response(&self)")?; + buf.writeln("}")?; + buf.writeln("}") + } + // Implement Rocket's `Responder`. #[cfg(feature = "with-rocket")] fn impl_rocket_responder(&mut self, buf: &mut Buffer) -> Result<(), CompileError> { -- cgit