dukeofharen / httplaceholder

A very flexible cross platform HTTP stub application.
MIT License
109 stars 4 forks source link

Feature/response string regex replace #309

Closed dukeofharen closed 1 year ago

dukeofharen commented 1 year ago

Pull request type

Please check the type of change your PR introduces:

What is the new behavior?

Added a response writer which makes it possible to perform a string or regex replace in the response body. Handy if you, for example, want to change the response body of a reverse proxy call.

- id: string-replace
  conditions:
    method: GET
    url:
      path:
        equals: /string-replace
  response:
    enableDynamicMode: true
    text: REPLACE THIS
    replace:
      - text: REPLACE
        ignoreCase: false
        replaceWith: OK
      - text: THIS
        ignoreCase: false
        replaceWith: ((uuid))

- id: regex-replace
  conditions:
    method: GET
    url:
      path:
        equals: /regex-replace
  response:
    text: Lorem ipsum dolor sit amet, consectetur adipiscing elit.
    enableDynamicMode: true
    replace:
      - regex: (ipsum|consectetur)
        replaceWith: ((query:queryString))
      - regex: (amet|elit)
        replaceWith: some text
  priority: 0
  tenant: integration
  enabled: true

Does this introduce a breaking change?