Patterns and syntax

The rules engine uses rules definition based on 3-levels of pattern matching:

  • endpoint: the first level allows to filter on which endpoints should match, by endpoint name.

  • request: the second level allows to filter on the request’s fingerprint.

  • stage: the fird level allows to filter on which stage the filter should apply.

Under those three levels, you’ll find a list of python code blocks that will be compiled and executed when the matching events occurs.

[rules."*"."*"]
on_request = """
request.headers["X-Forwarded-For"] = "Joe"
"""

[rules."httpbin-*"."GET /*"]
on_remote_response = """
response.headers["Cache-Control"] = "max-age=3600"
"""
rules:
  "*":
    "*":
      on_request: |
        request.headers["X-Forwarded-For"] = "Joe"
  "httpbin-*":
    "GET /*":
      on_remote_response: |
        response.headers["Cache-Control"] = "max-age=3600"