Deprecate extract::UrlParams and extract::UrlParamsMap (#138)

Use `extract::Path` instead. It supports everything the two other do,
and more.
This commit is contained in:
David Pedersen 2021-08-06 10:38:38 +02:00 committed by GitHub
parent a0ac8a5b78
commit 811b1d896c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 0 deletions

View file

@ -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

View file

@ -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,

View file

@ -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<T>(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<B, $head, $($tail,)*> FromRequest<B> 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<T> Deref for UrlParams<T> {
type Target = T;

View file

@ -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<ByteStr, ByteStr>);
#[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<B> FromRequest<B> for UrlParamsMap
where
B: Send,