Skip to content

Commit d3751f0

Browse files
committed
feat: make method matcher case-insensitive
1 parent f1975ce commit d3751f0

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/matchers.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use regex::Regex;
1616
use serde::Serialize;
1717
use serde_json::Value;
1818
use std::convert::TryInto;
19-
use std::str;
19+
use std::str::{self, FromStr};
2020
use url::Url;
2121

2222
/// Implement the `Match` trait for all closures, out of the box,
@@ -65,20 +65,17 @@ pub struct MethodExactMatcher(Method);
6565
/// Shorthand for [`MethodExactMatcher::new`].
6666
pub fn method<T>(method: T) -> MethodExactMatcher
6767
where
68-
T: TryInto<Method>,
69-
<T as TryInto<Method>>::Error: std::fmt::Debug,
68+
T: AsRef<str>,
7069
{
7170
MethodExactMatcher::new(method)
7271
}
7372

7473
impl MethodExactMatcher {
7574
pub fn new<T>(method: T) -> Self
7675
where
77-
T: TryInto<Method>,
78-
<T as TryInto<Method>>::Error: std::fmt::Debug,
76+
T: AsRef<str>,
7977
{
80-
let method = method
81-
.try_into()
78+
let method = Method::from_str(&method.as_ref().to_ascii_uppercase())
8279
.expect("Failed to convert to HTTP method.");
8380
Self(method)
8481
}

0 commit comments

Comments
 (0)