Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Considered dynamic fill of request based *on* the request? #15

Open
jimrobinson opened this issue Dec 8, 2017 · 1 comment
Open

Considered dynamic fill of request based *on* the request? #15

jimrobinson opened this issue Dec 8, 2017 · 1 comment

Comments

@jimrobinson
Copy link

I was wondering if you've ever considered whether or not it might be nice to allow for dynamically evaluating the request match mocks, similar to how you dynamically fill in the response once you've got a match?

The specific use case I was thinking of would be to allow someone to define a two yaml files that could in turn handle requests for many paths, but respond properly to qualifiers such as If-None-Match.

A set of examples, of course these don't work because there is no expansion on request header values, but I think they show the intent:

description:
  A request for an item with a weak etag, if
  if-none-match is provided but does not
  match then status 200 is returned.

request:
  method: HEAD|GET
  path: /data/:item/weak/:policy

response:
  statusCode: 200
  headers:
    Content-Type:
    - application/octet-stream
    Etag:
    - 'W/"{{ request.path.item }}"'
    Last-Modified:
    - Thu, 07 Dec 2017 23:15:34 GMT
    Cache-Control:
    - '{{request.path.policy}}'
  body:
    '{{ persist.entity.content }}'

persist:
  entity:
    '{{ request.path.item }}'
description:
  A request for an item with a weak etag, if
  if-none-match is provided and does match
  then status 304 and no body is returned.

request:
  method: HEAD|GET
  path: /data/:item/weak/:policy
  headers:
    If-None-Match:
    - 'W/"{{ request.path.item }}"'

response:
  statusCode: 304
  headers:
    Content-Type:
    - application/octet-stream
    Etag:
    - 'W/"{{ request.path.item }}"'
    Last-Modified:
    - Thu, 07 Dec 2017 23:15:34 GMT
    Cache-Control:
    - '{{request.path.policy}}'
@vtrifonov
Copy link
Owner

Looks useful, will take a look when I have some time. Thanks for the suggestion!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants