Rules are stored in YAML files and follow the following format:
- path: https://example.com # URL that this rule matches
method: POST # (optional) HTTP method. Default: GET
headers: # (optional) Headers to match on
Authorization: Bearer myToken
status: 500 # (optional) HTTP response status code. Default: 200
headers: # (optional) Response headers
# There are 2 ways to define a response body
body: Hello World # (optiona) Text is returned back
bodyFile: myResponse.json # (optional) Contents of the file are returned back
# Single YAML file can contain however many rules
- path: "https://example.com/.*" # Path can contain regular expressions
Matching is done by following principles:
- URL is matched first and needs to match exactly (or match a regular expression).
headerssection is present.
- All specified headers and their values have to be present in a request for it to match.
- If an HTTP(s) request has extra headers that are not specified in the rule, the rule will still match as if those extra headers were not there.
headerssection is not present then all requests headers will match (assuming that URL matched as well)
- Request body is not matched at the moment and is ignored.
- Matching stops at the first rule that fits the criteria. If you have multiple rules that match, only one of them will be used.