feat!: upgrade to matchit `0.8.0` (#140)

A copy of #134 but just with the matchit upgrade.

Thank you @matiu2 for raising the original PR
pull/142/head
Ethan Brierley 2024-04-10 09:05:51 +01:00 committed by GitHub
parent cb083ad66e
commit 0bdb2b6ef4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 4 additions and 3 deletions

View File

@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Removed `task_local_extensions` in favour of `http::Extensions`.
- All extensions must be `Clone` now.
- Replaced `with_arc` and `with_arc_init` methods with `with_box` and `with_box_init`.
- Support for `matchit` `0.8.0` - This means router matches like `/a/:some_var` need to be changed to `/a/{some_var}`
### Changed
- `RequestBuilder::try_clone` now clones the extensions.

View File

@ -20,7 +20,7 @@ reqwest-middleware = { version = "0.3.0", path = "../reqwest-middleware" }
anyhow = "1.0.70"
async-trait = "0.1.51"
matchit = "0.7.3"
matchit = "0.8.0"
http = "1"
reqwest = { version = "0.12.0", default-features = false }
tracing = "0.1.26"

View File

@ -267,9 +267,9 @@ impl OtelPathNames {
///
/// ```
/// # use reqwest_tracing::OtelPathNames;
/// let path_names = OtelPathNames::known_paths(["/payment/:paymentId"]).unwrap();
/// let path_names = OtelPathNames::known_paths(["/payment/{paymentId}"]).unwrap();
/// let path = path_names.find("/payment/payment-id-123");
/// assert_eq!(path, Some("/payment/:paymentId"));
/// assert_eq!(path, Some("/payment/{paymentId}"));
/// ```
pub fn find(&self, path: &str) -> Option<&str> {
self.0.at(path).map(|mtch| mtch.value.as_str()).ok()