LukeMathWalker / wiremock-rs

HTTP mocking to test Rust applications.
Apache License 2.0
617 stars 70 forks source link

add method for matching headers with a Regex #91

Closed wca closed 2 years ago

wca commented 2 years ago

Sometimes it's useful to be able to match a header based on a pattern, rather than having to specify a static string value. Mockito implements this via .match_header("name", Matcher::Regex(...)). This goes one step further, leveraging RegexSet.

LukeMathWalker commented 2 years ago

Thanks for the PR! What do you think is the value of using a RegexSet here instead of a simple Regex? How common do you think this use case is?

wca commented 2 years ago

@LukeMathWalker I'd use it, but I can't speak for others. Users could also just create multiple mocks for non-overlapping header regexes, given that MockBuilder doesn't have an or, or they could use RegexSet if it was an option.

LukeMathWalker commented 2 years ago

Ok, I'd suggest we do the following:

wca commented 2 years ago

@LukeMathWalker Eh, I'll just go along with using Regex instead, it's fine.