From 65aa3502ccac62dca12b2c06957777107b457a6a Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sat, 18 Dec 2021 03:49:32 +0000 Subject: [PATCH] soft deprecate `NormalizePath::default` --- CHANGES.md | 4 ++++ actix-http/src/error.rs | 2 +- src/middleware/normalize.rs | 14 +++++++++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index d9984224f..3a437fa1d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,10 @@ # Changes ## Unreleased - 2020-xx-xx +### Changed +* Soft-deprecate `NormalizePath::default()`, noting upcoming behavior change in v4. [#2529] + +[#2529]: https://github.com/actix/actix-web/pull/2529 ## 3.3.2 - 2020-12-01 diff --git a/actix-http/src/error.rs b/actix-http/src/error.rs index e93c077af..70d2f8e8e 100644 --- a/actix-http/src/error.rs +++ b/actix-http/src/error.rs @@ -55,7 +55,7 @@ impl Error { /// Similar to `as_response_error` but downcasts. pub fn as_error(&self) -> Option<&T> { - ResponseError::downcast_ref(self.cause.as_ref()) + ::downcast_ref(self.cause.as_ref()) } } diff --git a/src/middleware/normalize.rs b/src/middleware/normalize.rs index ac8ad71d5..6bd3bcb7b 100644 --- a/src/middleware/normalize.rs +++ b/src/middleware/normalize.rs @@ -31,7 +31,7 @@ impl Default for TrailingSlash { } } -#[derive(Default, Clone, Copy)] +#[derive(Clone, Copy)] /// `Middleware` to normalize request's URI in place /// /// Performs following: @@ -56,6 +56,18 @@ impl Default for TrailingSlash { pub struct NormalizePath(TrailingSlash); +impl Default for NormalizePath { + fn default() -> Self { + log::warn!( + "`NormalizePath::default()` is deprecated. The default trailing slash behavior will \ + change in v4 from `Always` to `Trim`. Update your call to `NormalizePath::new(...)` to \ + avoid inaccessible routes when upgrading." + ); + + Self(TrailingSlash::default()) + } +} + impl NormalizePath { /// Create new `NormalizePath` middleware with the specified trailing slash style. pub fn new(trailing_slash_style: TrailingSlash) -> Self {