diff options
author | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2021-12-21 23:17:14 +0100 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2022-01-04 21:30:15 +0100 |
commit | 42d80ad6cdb1a4ff9ff8fcc088b25d5f7b66a393 (patch) | |
tree | 7faca2dc4d177a109e4c7849a1c1f5f24af72999 /askama_actix/src | |
parent | 6c8c0d63065608ca079110fe20721b7c4d8594f8 (diff) | |
download | askama-42d80ad6cdb1a4ff9ff8fcc088b25d5f7b66a393.tar.gz askama-42d80ad6cdb1a4ff9ff8fcc088b25d5f7b66a393.tar.bz2 askama-42d80ad6cdb1a4ff9ff8fcc088b25d5f7b66a393.zip |
askama_actix: revert to actix-web v3 for release
Diffstat (limited to '')
-rw-r--r-- | askama_actix/src/lib.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/askama_actix/src/lib.rs b/askama_actix/src/lib.rs index baf9fd6..d9ac62d 100644 --- a/askama_actix/src/lib.rs +++ b/askama_actix/src/lib.rs @@ -3,23 +3,23 @@ pub use askama::*; use bytes::BytesMut; -use actix_web::{error::ErrorInternalServerError, HttpResponse}; +use actix_web::{error::ErrorInternalServerError, Error, HttpResponse}; pub trait TemplateToResponse { - fn to_response(&self) -> HttpResponse; + fn to_response(&self) -> std::result::Result<HttpResponse, Error>; } impl<T: askama::Template> TemplateToResponse for T { - fn to_response(&self) -> HttpResponse { + fn to_response(&self) -> std::result::Result<HttpResponse, Error> { let mut buffer = BytesMut::with_capacity(T::SIZE_HINT); if self.render_into(&mut buffer).is_err() { - return ErrorInternalServerError("Template parsing error").error_response(); + return Err(ErrorInternalServerError("Template parsing error")); } let ctype = askama::mime::extension_to_mime_type(T::EXTENSION.unwrap_or("txt")).to_string(); - HttpResponse::Ok() + Ok(HttpResponse::Ok() .content_type(ctype.as_str()) - .body(buffer.freeze()) + .body(buffer.freeze())) } } |