mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-12 21:35:55 +01:00
Updated Request Matching (markdown)
@@ -4,11 +4,17 @@ WireMock.Net supports matching of requests to stubs and verification queries usi
|
||||
* Path
|
||||
* URL
|
||||
* HTTP Method
|
||||
* Query parameters
|
||||
* Headers
|
||||
* [Query parameters](#query-parameters)
|
||||
* [Headers](#headers)
|
||||
* Cookies
|
||||
* Request Body
|
||||
|
||||
## Generic information on matchers:
|
||||
|
||||
Most matchers have 2 extra properties:
|
||||
- IgnoreCase = define that the matcher should match ignoring the case
|
||||
- RejectOnMatch = define that when the matcher does match successfully, this should be counted as a invalid (non-matching) match
|
||||
|
||||
## Example Matching for the elements
|
||||
|
||||
### Query Parameters
|
||||
@@ -39,6 +45,47 @@ server
|
||||
}
|
||||
```
|
||||
|
||||
### Headers
|
||||
#### C#
|
||||
``` c#
|
||||
// todo
|
||||
```
|
||||
|
||||
#### JSON
|
||||
``` json
|
||||
{
|
||||
"Request": {
|
||||
"Headers": [
|
||||
{
|
||||
"Name": "api-key",
|
||||
"Matchers": [
|
||||
{
|
||||
"Name": "WildcardMatcher",
|
||||
"Pattern": "abc*"
|
||||
"IgnoreCase": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Note that when you want to match on a missing header, you need to use this mapping:
|
||||
``` json
|
||||
{
|
||||
"Request": {
|
||||
"Headers": [
|
||||
{
|
||||
"Name": "api-key",
|
||||
"IgnoreCase": true,
|
||||
"RejectOnMatch": true
|
||||
}
|
||||
}
|
||||
]
|
||||
```
|
||||
This means that when the header-key `api-key` (ignoring the casing) is missing the header mapping will match because `RejectOnMatch` is `true`.
|
||||
|
||||
# :two: Matchers
|
||||
The following paragraphs describe in detail which matchers can be used.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user