Can ExactMatcher (on Request) include IgnoreCase?
I've got an API I've mocked, a nice and simple one, which is nothing but a kind of lookup service so just simple restful gets. An example might look like: [HttpGet] /lookup/{id}
The Request part of my mapping: "Request": { "Path": { "Matchers": [ { "Name": "ExactMatcher", "Pattern": "/lookup/12345" } ] },
This gives me the ability to set a bunch of specific responses for various values. In order to have a "catchall", I've also got this other mapping: "Request": { "Path": { "Matchers": [ { "Name": "WildcardMatcher", "Pattern": "/lookup/*", "IgnoreCase": true } ] }, This serves me well as I can define a bunch of custom cases, but also have a catch all for other values where I want to return a default response.
The problem is that the ExactMatcher doesn't appear to support IgnoreCase which to a degree I understand... it's an exact match, but in truth, casing in a URL's route is generally going to work fine regardless of case: /lookup/12345 and /Lookup/1235
are going to work the same for the vast majority of API calls and I'd argue remain an "exact match" in most cases (most cases, so the IgnoreCase option remains a good choice).
Can't you just use a WildcardMatcher with /lookup/12345 and ignorecase = true?
If I do that, then my WildCard one I setup now catches everything if the path case is different.
Example: ExactMatcher: /lookup/12345 return: { "id": 1 }
WildcardMatcher: /lookup/* IgnoreCase: true return: { "id": 2 }
Test cases: /lookup/12345 will return { "id": 1 }
/Lookup/12345 will return { "id": 2 }, but I want { "id": 1 }
Ah.
In that case I think regexmatcher will be the best choice for you: https://github.com/WireMock-Net/WireMock.Net/wiki/Request-Matching#regular-expression-matching-regexmatcher
Which is powerfull because it's regex, and also supports ignore case.
It’s not ideal for my use case but I can make it work in conjunction with Priority:
“Priority”: 1 “Request": { "Path": { "Matchers": [ { "Name": "RegexMatcher", "Pattern": "/lookup/12345$", “IgnoreCase”: true } ] },
“Priority”: 2, "Request": { "Path": { "Matchers": [ { "Name": "WildcardMatcher", "Pattern": "/lookup/*", "IgnoreCase": true } ] },
@mattisking I did update the ExactMather to support IgnoreCase.
please test preview version 1.5.6-ci-16453
@mattisking Can you test this?
I will test it today. Sorry, Business travel.
@mattisking Did you time to test?
@mattisking ; can you please test this?
@mattisking , if you have time, can you please test this?
(Then I can merge this to master)
@mattisking Did you have time yet to verify?
https://github.com/WireMock-Net/WireMock.Net/pull/817
PR will be merged. A new NuGet will be released this weekend,