Replace String in Response Body

Replace a string in the incoming request body

Configuration#

{
  "name": "my-replace-string-outbound-policy",
  "policyType": "replace-string-outbound",
  "handler": {
    "export": "ReplaceStringOutboundPolicy",
    "module": "$import(@zuplo/runtime)",
    "options": {
      "mode": "regexp",
      "match": "https://example.com/api/(v1|v0)/",
      "replaceWith": "https://my-gateway.com/v1/"
    }
  }
}

Options#

  • name the name of your policy instance. This is used as a reference in your routes.
  • policyType the identifier of the policy. This is used by the Zuplo UI. Value should be replace-string-outbound.
  • handler/export The name of the exported type. Value should be ReplaceStringOutboundPolicy.
  • handler/module the module containing the policy. Value should be $import(@zuplo/runtime).
  • handler/options The options for this policy:
    • mode

      The type of string replacement to perform

    • match

      The pattern to match

    • replaceWith

      The value to each match is replaced with

Was this article helpful?

Do you have any questions?Contact us
Check out ourproduct changelog