🖥️ Try it yourself
$ spoof scaffold -o example-header-matching
You can provide a list of headers, and their values, in the Request configuration, like this:
"request": {
"httpMethod": "GET",
"path": "/api/example-header-matching",
"headers": {
"Accept": "application/json"
}
},(other parts of the JSON body have been hidden for clarity. See the scaffolded example for a complete file)
In the example above, the API will only return a response if the request contains an Accept header with the value application/json.
Any request without this header will return a HTTP 404 (Not Found)
You can provide mulitple headers (including custom headers), in which case all must match:
"request": {
"httpMethod": "GET",
"path": "/api/example-header-matching",
"headers": {
"Accept": "application/json",
"x-api-key": "1234",
}
},➡️ Next: Fixed Responses