Skip to content

Commit

Permalink
Merge pull request #182 from czyba/master
Browse files Browse the repository at this point in the history
actix-web >= 2.0.0 support
  • Loading branch information
lambda-fairy authored Mar 21, 2020
2 parents c119dbc + 34d1b6a commit dfa7d5a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Change Log

## [Unreleased]
- [Changed] Update Actix to 2.0.0. Actix 1.0.0 is no longer supported.
[#182](https://github.com/lambda-fairy/maud/pull/182)

## [0.21.0] - 2019-07-01

Expand Down
6 changes: 5 additions & 1 deletion maud/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@ description = "Compile-time HTML templates."
categories = ["template-engine"]
edition = "2018"

[features]
actix-web = ["actix-web-dep", "futures"]

[dependencies]
maud_htmlescape = { version = "0.17.0", path = "../maud_htmlescape" }
maud_macros = { version = "0.21.0", path = "../maud_macros" }
iron = { version = ">= 0.5.1, < 0.7.0", optional = true }
rocket = { version = ">= 0.3, < 0.5", optional = true }
actix-web = { version = "1.0.0", optional = true, default-features = false }
futures = { version = "0.3.0", optional = true }
actix-web-dep = { version = "2.0.0", optional = true, default-features = false, package = "actix-web" }

[dev-dependencies]
compiletest_rs = { version = "0.3.19", features = ["stable"] }
Expand Down
9 changes: 5 additions & 4 deletions maud/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#![doc(html_root_url = "https://docs.rs/maud/0.21.0")]

#[cfg(feature = "actix-web")] extern crate actix_web;
#[cfg(feature = "actix-web")] extern crate actix_web_dep;
#[cfg(feature = "iron")] extern crate iron;
#[cfg(feature = "rocket")] extern crate rocket;

Expand Down Expand Up @@ -194,13 +194,14 @@ mod rocket_support {
#[cfg(feature = "actix-web")]
mod actix_support {
use crate::PreEscaped;
use actix_web::{Responder, HttpResponse, HttpRequest, Error};
use actix_web_dep::{Responder, HttpResponse, HttpRequest, Error};
use futures::future::{ok, Ready};

impl Responder for PreEscaped<String> {
type Error = Error;
type Future = Result<HttpResponse, Self::Error>;
type Future = Ready<Result<HttpResponse, Self::Error>>;
fn respond_to(self, _req: &HttpRequest) -> Self::Future {
Ok(HttpResponse::Ok()
ok(HttpResponse::Ok()
.content_type("text/html; charset=utf-8")
.body(self.0))
}
Expand Down

0 comments on commit dfa7d5a

Please sign in to comment.