Skip to content

Request matching headers #181

Discussion options

You must be logged in to vote

There is a bug in Camouflage that prevents request matching using headers. I have made the required changes and it should work in 0.8.2 in following manner.

{{#if (capture from='headers' key='Authorization') }}
HTTP/1.1 200 OK
Content-Type: application/json

{
    "response": "response if auth header is present."
}
{{else}}
HTTP/1.1 401 Unauthorized
Content-Type: application/json

{
    "response": "response if no auth header present."
}
{{/if}}

If you want to validate a given header against a specific value, the mock file would be as shown below:

{{#is (capture from='headers' key='Authorization') 'Basic c2h1YmhlbmR1Om1hZGh1a2Fy' }}
HTTP/1.1 200 OK
Content-Type: application/json

{
    "…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@hurena-BR
Comment options

@shubhendumadhukar
Comment options

Answer selected by hurena-BR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants