Skip to content

Commit 98bd6d2

Browse files
fix(deps): update rust crate askama to 0.13.0 (#409)
* fix(deps): update rust crate askama to 0.13.0 * fix: html templating --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Guðmundur Björn Birkisson <[email protected]>
1 parent 88b8b48 commit 98bd6d2

File tree

3 files changed

+41
-60
lines changed

3 files changed

+41
-60
lines changed

Cargo.lock

Lines changed: 34 additions & 49 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ sqlx = { version = "0.8", features = [
4646
# Web
4747
actix-web = "4"
4848
tracing-actix-web = "0.7.9"
49-
askama = { version = "0.12.1" }
49+
askama = { version = "0.13.0" }
5050

5151
# Serialization
5252
serde = { version = "1", features = ["derive"] }

src/server/hx/render.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
use actix_web::ResponseError;
2-
use actix_web::http::StatusCode;
3-
use actix_web::http::header::HeaderValue;
4-
use actix_web::{HttpResponse, HttpResponseBuilder};
2+
use actix_web::web::Html;
53
use thiserror::Error;
64

7-
pub(super) type Response = Result<HttpResponse, ServerError>;
5+
pub(super) type Response = Result<Html, ServerError>;
86

97
#[derive(Error, Debug)]
108
pub(super) enum ServerError {
@@ -22,11 +20,9 @@ pub(super) trait TemplatedResponse {
2220

2321
impl<T: askama::Template> TemplatedResponse for T {
2422
fn render_response(&self) -> Response {
25-
Ok(HttpResponseBuilder::new(StatusCode::OK)
26-
.content_type(HeaderValue::from_static(T::MIME_TYPE))
27-
.body(
28-
self.render()
29-
.map_err(|e| ServerError::TemplateError(e.into()))?,
30-
))
23+
Ok(Html::new(
24+
self.render()
25+
.map_err(|e| ServerError::TemplateError(e.into()))?,
26+
))
3127
}
3228
}

0 commit comments

Comments
 (0)