smocker-dev / smocker

Smocker is a simple and efficient HTTP mock server and proxy
https://smocker.dev
MIT License
1.13k stars 59 forks source link

Support optional query parameters #291

Open stefan-schweiger opened 7 months ago

stefan-schweiger commented 7 months ago

It would be great if not all query parameters would be required. E.g. if I set something up like the config below which does a "ShouldMatch" with .* I think a request like this should also be accepted POST /sms.do?to=test.

- request:
    method: POST
    path: /sms.do
    query_params:
      from:
        matcher: ShouldMatch
        value: '.*'
      to:
        matcher: ShouldMatch
        value: '.+'
  response:
    status: 200
    body: |-
      {
        "count": 1,
        "error": null
      }

Overall I also think there should be an option to just ignore all query parameters and only match on the path, because honestly in the above example I couldn't even care less about the actual query parameters, I just always want my response returned for all requests.

Sawiq commented 7 months ago

If I understand your problem correctly, you can simply not specify query params' matcher(s) at all...

stefan-schweiger commented 7 months ago

If I don't specify any parameters it will just 404..