Skip to content

Latest commit

 

History

History
53 lines (36 loc) · 1.04 KB

File metadata and controls

53 lines (36 loc) · 1.04 KB

Request Header Matching


🖥️ Try it yourself

$ spoof scaffold -o example-header-matching

Basic 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