Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.draskencloud.com/llms.txt

Use this file to discover all available pages before exploring further.

Header injection rules let you add, remove, or transform headers on the forwarded request without touching your backend code.

Static Headers

Add fixed headers to every upstream request:
{
  "headers": {
    "add": {
      "X-Gateway": "nexus",
      "X-Internal-Source": "gateway"
    },
    "remove": ["X-Powered-By", "Server"],
    "response_add": {
      "X-Content-Type-Options": "nosniff"
    },
    "response_remove": ["X-Frame-Options"]
  }
}

Dynamic Header Injection

Inject values extracted from the request or authenticated token:
{
  "headers": {
    "inject": [
      {
        "header": "X-User-Id",
        "from": "metadata.user_id"
      },
      {
        "header": "X-Request-Path",
        "from": "request.path"
      },
      {
        "header": "X-Api-Version",
        "from": "request.query.version",
        "default": "v1"
      }
    ]
  }
}

Injection Sources

SourceDescription
metadata.<key>Value from the authenticated token’s metadata map
request.header.<name>Value of an incoming request header
request.pathThe request path
request.methodThe HTTP method (uppercased)
request.query.<param>A named query-string parameter

Required Headers

Reject requests that are missing specific headers:
{
  "headers": {
    "required": ["X-Tenant-ID", "X-Request-ID"]
  }
}
Requests missing these headers return 400 Bad Request.

Header Validation

Validate header values against rules:
{
  "headers": {
    "validate": [
      {
        "name": "X-Api-Version",
        "kind": "oneof",
        "value": ["v1", "v2"]
      },
      {
        "name": "X-Tenant-ID",
        "kind": "regex",
        "value": "^[a-z0-9-]{3,64}$"
      }
    ]
  }
}
KindDescription
exactValue must match exactly
regexValue must match the regex pattern
oneofValue must be one of the listed strings

Token Metadata as Headers

When using API key auth, attach metadata to the token at creation time and inject it as headers:
# Create token with metadata
curl -X POST .../tokens \
  -d '{
    "name": "Mobile App",
    "scopes": ["read"],
    "metadata": {
      "tenant_id": "acme",
      "plan": "pro"
    }
  }'
Then inject in the revision policy:
{
  "headers": {
    "inject": [
      {"header": "X-Tenant-ID", "from": "metadata.tenant_id"},
      {"header": "X-Plan", "from": "metadata.plan"}
    ]
  }
}