Rules Engine

HARP's Rules Engine allows to fine-tune nearly every aspect of a transaction's lifecycle, from request to response, using pattern matching, lifecycle events and python code.

Transaction Lifecycle

Transactions (usually a request and a response) will trigger different events when processed by the proxy, allowing to override settings and content at will.

transaction lifecycle for rules engine

Pattern Matching

Rules are defined using a simple YAML syntax, allowing to match requests and responses using a combination of regexp-like patterns to match endpoints names, http command (GET /foo) and lifecycle events.

rules:

      # Matches all requests to endpoints named starting with "api-"
      "api-*":

        # Matches all GET requests to endpoints starting with "/v2/" (GET only)
        "GET /v2/*":

          # Event triggered when the remote response is ready
          on_http_response:

            # Run some python to override the cache-control header
            response.headers["cache-control"] = "public, max-age=3600"

It's just Python!

Rules are written using plain python, that will get compiled to bytecode at configuration parsing time, allowing for syntax checks on start, and for efficient execution.

One simple system to rule-em-all

By having no opinion on what the rules will apply, we allow for a wide range of use-cases, even the one we didn't think about (or that did not exist at time of writing). You can fine-tune existings systems (like the HTTP cache), create new ones (like a custom header injection system) or set vendor-specific attributes that your custom unpublished code will use.

Ready to give HARP Proxy a try?

HARP Proxy is free and open-source, installing it usually takes under 5 minutes. For advanced features and support, check out our Enterprise Edition.