aboutsummaryrefslogtreecommitdiffstats
path: root/askama_shared
diff options
context:
space:
mode:
authorLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-09-06 20:03:22 +0200
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-09-06 20:03:47 +0200
commit9c4f37c17e41930b3e2b085861fa7c4bf71a9db6 (patch)
tree0bfd99bc881734f2b9d094efd1dce6c78999d1fd /askama_shared
parent0129365d1e13ec2d80945f263dcf06a022af7592 (diff)
downloadaskama-9c4f37c17e41930b3e2b085861fa7c4bf71a9db6.tar.gz
askama-9c4f37c17e41930b3e2b085861fa7c4bf71a9db6.tar.bz2
askama-9c4f37c17e41930b3e2b085861fa7c4bf71a9db6.zip
Decrease coupling with Rocket in generated code
Diffstat (limited to '')
-rw-r--r--askama_shared/src/generator.rs12
1 files changed, 2 insertions, 10 deletions
diff --git a/askama_shared/src/generator.rs b/askama_shared/src/generator.rs
index e3454b4..4590816 100644
--- a/askama_shared/src/generator.rs
+++ b/askama_shared/src/generator.rs
@@ -699,21 +699,13 @@ impl<'a> Generator<'a> {
fn impl_responder(&mut self, state: &'a State) {
self.write_header(state, "::askama::rocket::Responder<'r>", &vec!["'r"]);
self.writeln("fn respond_to(self, _: &::askama::rocket::Request) \
- -> ::std::result::Result<\
- ::askama::rocket::Response<'r>, ::askama::rocket::Status> {");
- self.writeln("let rsp = self.render().map_err(\
- |_| ::askama::rocket::Status::InternalServerError)?;");
+ -> ::askama::rocket::Result<'r> {");
- self.writeln("::askama::rocket::Response::build()");
- self.indent();
let ext = match state.input.path.extension() {
Some(s) => s.to_str().unwrap(),
None => "txt",
};
- self.writeln(&format!(".header(::askama::rocket::ContentType::from_extension({:?})\
- .unwrap())", ext));
- self.writeln(".sized_body(::std::io::Cursor::new(rsp))");
- self.writeln(".ok()");
+ self.writeln(&format!("::askama::rocket::respond(&self, {:?})", ext));
self.dedent();
self.writeln("}");