diff --git a/CHANGELOG.md b/CHANGELOG.md index dd955803..60c83b52 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fix `Query` and `Form` extractors giving bad request error when query string is empty. ([#117](https://github.com/tokio-rs/axum/pull/117)) - Add `Path` extractor. ([#124](https://github.com/tokio-rs/axum/pull/124)) - Fixed the implementation of `IntoResponse` of `(HeaderMap, T)` and `(StatusCode, HeaderMap, T)` would ignore headers from `T` ([#137](https://github.com/tokio-rs/axum/pull/137)) +- Deprecate `extract::UrlParams` and `extract::UrlParamsMap`. Use `extract::Path` instead ([#138](https://github.com/tokio-rs/axum/pull/138)) ## Breaking changes diff --git a/src/extract/mod.rs b/src/extract/mod.rs index 5edfe64f..ae99398c 100644 --- a/src/extract/mod.rs +++ b/src/extract/mod.rs @@ -267,6 +267,7 @@ mod url_params; mod url_params_map; #[doc(inline)] +#[allow(deprecated)] pub use self::{ connect_info::ConnectInfo, content_length_limit::ContentLengthLimit, diff --git a/src/extract/url_params.rs b/src/extract/url_params.rs index d7869aa6..84b97db5 100644 --- a/src/extract/url_params.rs +++ b/src/extract/url_params.rs @@ -28,6 +28,7 @@ use std::{ops::Deref, str::FromStr}; /// Note that you can only have one URL params extractor per handler. If you /// have multiple it'll response with `500 Internal Server Error`. #[derive(Debug)] +#[deprecated(since = "0.1.3", note = "Use `axum::extract::Path` instead.")] pub struct UrlParams(pub T); macro_rules! impl_parse_url { @@ -35,6 +36,7 @@ macro_rules! impl_parse_url { ( $head:ident, $($tail:ident),* $(,)? ) => { #[async_trait] + #[allow(deprecated)] impl FromRequest for UrlParams<($head, $($tail,)*)> where $head: FromStr + Send, @@ -88,6 +90,7 @@ macro_rules! impl_parse_url { impl_parse_url!(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16); +#[allow(deprecated)] impl Deref for UrlParams { type Target = T; diff --git a/src/extract/url_params_map.rs b/src/extract/url_params_map.rs index a18705d6..f05e5fe7 100644 --- a/src/extract/url_params_map.rs +++ b/src/extract/url_params_map.rs @@ -25,8 +25,10 @@ use std::{collections::HashMap, str::FromStr}; /// Note that you can only have one URL params extractor per handler. If you /// have multiple it'll response with `500 Internal Server Error`. #[derive(Debug)] +#[deprecated(since = "0.1.3", note = "Use `axum::extract::Path` instead.")] pub struct UrlParamsMap(HashMap); +#[allow(deprecated)] impl UrlParamsMap { /// Look up the value for a key. pub fn get(&self, key: &str) -> Option<&str> { @@ -43,6 +45,7 @@ impl UrlParamsMap { } #[async_trait] +#[allow(deprecated)] impl FromRequest for UrlParamsMap where B: Send,