Template Engine

Dynamic variable substitution using {{variable.path}} syntax

Overview

The template engine provides dynamic variable substitution using {{variable.path}} syntax throughout your configuration. It allows you to inject values from request context, session data, configuration, secrets, and authentication into any configuration field at runtime.

Template variables can be used in request modifiers, response modifiers, action URLs, webhook hooks, and error pages.

Capabilities

  • Scopes: request, variables, secrets, config, session, env, server
  • Nested path access with dot notation: {{ request.headers.x_api_key }}
  • Usable in request and response modifiers, action URLs, webhook hooks, and error pages

Example

Inject request context, secrets, and callback data into upstream headers:

proxy:
  http_bind_port: 8080

origins:
  "api.example.com":
    action:
      type: proxy
      url: https://test.sbproxy.dev
    variables:
      api_version: v2
    request_modifiers:
      - headers:
          set:
            X-API-Version: "{{ variables.api_version }}"
            X-API-Key: "{{ secrets.api_key }}"

Test it:

curl -H "Host: api.example.com" http://localhost:8080/