diff --git a/CHANGELOG.md b/CHANGELOG.md index 596d9e9e..6c9a0eb5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ [#320](https://github.com/lambda-fairy/maud/pull/320) - Update to axum-core 0.1. This requires axum 0.4 [#325](https://github.com/lambda-fairy/maud/pull/325) +- Update to `actix-web` 4.0. + [#331](https://github.com/lambda-fairy/maud/pull/331) ## [0.23.0] - 2021-11-10 diff --git a/doctest/Cargo.toml b/doctest/Cargo.toml index fb8d674d..ad029368 100644 --- a/doctest/Cargo.toml +++ b/doctest/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Chris Wong "] edition = "2018" [dependencies] -actix-web = "3" +actix-web = { version = "4.0.0-rc.2", default-features = false, features = ["macros"] } ammonia = "3" maud = { path = "../maud", features = ["actix-web", "rocket", "tide", "axum"] } pulldown-cmark = "0.8" diff --git a/maud/Cargo.toml b/maud/Cargo.toml index 45c9ef94..939801aa 100644 --- a/maud/Cargo.toml +++ b/maud/Cargo.toml @@ -13,17 +13,17 @@ edition = "2021" [features] default = [] -axum = ["axum-core", "http"] # Web framework integrations actix-web = ["actix-web-dep", "futures-util"] +axum = ["axum-core", "http"] [dependencies] maud_macros = { version = "0.23.0", path = "../maud_macros" } itoa = { version = "0.4.8", default-features = false, features = ["i128"] } rocket = { version = ">= 0.3, < 0.5", optional = true } futures-util = { version = "0.3.0", optional = true, default-features = false } -actix-web-dep = { package = "actix-web", version = ">= 2, < 4", optional = true, default-features = false } +actix-web-dep = { package = "actix-web", version = "4", optional = true, default-features = false } tide = { version = "0.16.0", optional = true, default-features = false } axum-core = { version = "0.1", optional = true } http = { version = "0.2", optional = true } diff --git a/maud/src/lib.rs b/maud/src/lib.rs index 9450f2c2..73ac24f5 100644 --- a/maud/src/lib.rs +++ b/maud/src/lib.rs @@ -262,17 +262,17 @@ mod rocket_support { #[cfg(feature = "actix-web")] mod actix_support { use crate::PreEscaped; - use actix_web_dep::{Error, HttpRequest, HttpResponse, Responder}; + use actix_web_dep::{http::header, HttpRequest, HttpResponse, Responder}; use alloc::string::String; - use futures_util::future::{ok, Ready}; impl Responder for PreEscaped { - type Error = Error; - type Future = Ready>; - fn respond_to(self, _req: &HttpRequest) -> Self::Future { - ok(HttpResponse::Ok() - .content_type("text/html; charset=utf-8") - .body(self.0)) + type Body = String; + + fn respond_to(self, _req: &HttpRequest) -> HttpResponse { + HttpResponse::Ok() + .content_type(header::ContentType::html()) + .message_body(self.0) + .unwrap() } } }