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

Mock with path param #262

Closed aswzen closed 1 year ago

aswzen commented 1 year ago

How to create a mock with a path params

For example hello/world/{param}

- request: method: GET path: '/hello/world/{param}' response: status: 200

The the param sent to response 'Hello {param}"

Thanks Git

gwleclerc commented 1 year ago

Hi, you can use a string matcher to do that. https://smocker.dev/technical-documentation/mock-definition.html#string-matchers

- request:
    methode: GET
    path:
      matcher: ShouldMatch
      value: /hello/world/.*
  response:
    status: 200

And if you want to use it in the response you can use a dynamic response using lua or go templates https://smocker.dev/technical-documentation/mock-definition.html#format-of-dynamic-response-section