request_data
: If the inbound request contained any query data or form data, it will be available in this object. For the header injector Tyk will format this data as key:value1,value2,valueN;key:value1,value2
etc.path_parts
: The components of the path, split on /
. These values should be in the format of a comma delimited list.token
: The inbound raw token (if bearer tokens are being used) of this user.path
: The path that is being requested.remote_addr
: The IP address of the connecting client.request_id
Allows the injection of request correlation ID (for example X-Request-ID)jwt_claims_CLAIMNAME
- If JWT tokens are being used, then each claim in the JWT is available in this format to the context processor. CLAIMNAME
is case sensitive so use the exact claim.cookies_COOKIENAME
- If there are cookies, then each cookie is available in context processor in this format. COOKIENAME
is case sensitive so use the exact cookie name and replace any -
in the cookie name with _
.headers_HEADERNAME
- Headers are obviously exposed in context processor. You can access any header in the request using the following format: Convert the first letter in each word of an incoming header is to Capital Case. This is due to the way GoLang handles header parsing. You also need to replace any -
in the HEADERNAME
name with _
.test-header
, the syntax would be $tyk_context.headers_Test_Header
.$tyk_context.CONTEXTVARIABLES
. See URL Rewriting for more details.$tyk_context.CONTEXTVARIABLES
. See Request Headers for more details.{{ ._tyk_context.CONTEXTVARIABLES }}
. See Body Transforms for more details.{{ index ._tyk_context.path_parts 0 }}
in the Go Template in a Body Transform will expose the first entry in the path_parts
list.URL Rewriter and Header Transform middleware cannot iterate through list indices.APIs
from the System Management
menuAdvanced Options
tab and then select the Enable context variables
optionenable_context_vars
to your API definition file at root level and set it to true
.
If you are using Tyk Operator, set the field spec.enable_context_vars
to true
.
The example API Definition below enabled context variable: