diff --git a/CHANGES.md b/CHANGES.md index b2cc1402e..9497875a4 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -8,7 +8,7 @@ ### Changed * Associated type `FromRequest::Config` was removed. [#2233] * Inner field made private on `web::Payload`. [#2384] -* `middleware::Condition::new` was removed in favour of `middleware::conditionally` +* `middleware::Condition::new` was deprecated in favour of `middleware::conditionally` [#2233]: https://github.com/actix/actix-web/pull/2233 [#2362]: https://github.com/actix/actix-web/pull/2362 diff --git a/src/middleware/condition.rs b/src/middleware/condition.rs index 2fd8465f2..038a07675 100644 --- a/src/middleware/condition.rs +++ b/src/middleware/condition.rs @@ -18,7 +18,7 @@ use std::sync::Mutex; /// /// # Examples /// ``` -/// use actix_web::middleware::{Condition, NormalizePath, TrailingSlash, conditionally, optionally, optionally_fut}; +/// use actix_web::middleware::{Condition, NormalizePath, TrailingSlash, conditionally, optionally, optionally_fut, futurally}; /// use actix_web::App; /// use std::future::ready; /// @@ -38,6 +38,13 @@ pub struct Condition(Rc>) where F: Future> + Unpin + 'static; +impl Condition>> { + #[deprecated(since = "4.0.0", note = "Use middleware::conditionally instead")] + pub fn new(enable: bool, transformer: T) -> Self { + conditionally(enable, transformer) + } +} + pub fn futurally(transformer: F) -> Condition where F: Future> + Unpin + 'static,