re-add deprecated to Condition::new remove breaking changes.

This commit is contained in:
Akos Vandra 2021-09-30 13:03:00 +02:00
parent 613be74faf
commit 4a45606b9f
2 changed files with 9 additions and 2 deletions

View File

@ -8,7 +8,7 @@
### Changed ### Changed
* Associated type `FromRequest::Config` was removed. [#2233] * Associated type `FromRequest::Config` was removed. [#2233]
* Inner field made private on `web::Payload`. [#2384] * 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 [#2233]: https://github.com/actix/actix-web/pull/2233
[#2362]: https://github.com/actix/actix-web/pull/2362 [#2362]: https://github.com/actix/actix-web/pull/2362

View File

@ -18,7 +18,7 @@ use std::sync::Mutex;
/// ///
/// # Examples /// # 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 actix_web::App;
/// use std::future::ready; /// use std::future::ready;
/// ///
@ -38,6 +38,13 @@ pub struct Condition<T, F>(Rc<Mutex<F>>)
where where
F: Future<Output = Option<T>> + Unpin + 'static; F: Future<Output = Option<T>> + Unpin + 'static;
impl<T> Condition<T, Ready<Option<T>>> {
#[deprecated(since = "4.0.0", note = "Use middleware::conditionally instead")]
pub fn new(enable: bool, transformer: T) -> Self {
conditionally(enable, transformer)
}
}
pub fn futurally<T, F>(transformer: F) -> Condition<T, F> pub fn futurally<T, F>(transformer: F) -> Condition<T, F>
where where
F: Future<Output = Option<T>> + Unpin + 'static, F: Future<Output = Option<T>> + Unpin + 'static,