Skip to content
This repository was archived by the owner on Nov 9, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ You can use any of the current request headers, query params, and captured URI g
| header | `$(headers.<header_name>)`, `$(headers["<Header-Name>"])` or `$(headers["<header-name>"])`)
| querystring | `$(query_params.<query-param-name>)` or `$(query_params["<query-param-name>"])`)
| captured URIs | `$(uri_captures.<group-name>)` or `$(uri_captures["<group-name>"])`)
| Nginx var | `$(ngx_var.<var-name>)` or `$(ngx_var["<var-name>"])`)

To escape a template, wrap it inside quotes and pass it inside another template.<br>
`$('$(some_escaped_template)')`
Expand Down
7 changes: 6 additions & 1 deletion kong/plugins/request-transformer/access.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ local get_raw_body = kong.request.get_raw_body
local set_raw_body = kong.service.request.set_raw_body
local encode_args = ngx.encode_args
local ngx_decode_args = ngx.decode_args
local ngx_var = ngx.var
local type = type
local str_find = string.find
local pcall = pcall
Expand Down Expand Up @@ -83,6 +84,9 @@ local __meta_environment = {
uri_captures = function(self)
return (ngx.ctx.router_matches or EMPTY).uri_captures or EMPTY
end,
ngx_var = function(self)
return ngx_var or EMPTY
end,
shared = function(self)
return ((kong or EMPTY).ctx or EMPTY).shared or EMPTY
end,
Expand Down Expand Up @@ -114,6 +118,7 @@ local function clear_environment(conf)
rawset(template_environment, "headers", nil)
rawset(template_environment, "query_params", nil)
rawset(template_environment, "uri_captures", nil)
rawset(template_environment, "ngx_var", nil)
rawset(template_environment, "shared", nil)
end

Expand Down Expand Up @@ -518,7 +523,7 @@ local function transform_uri(conf)
"` rendered to `", res, "`")

if res then
ngx.var.upstream_uri = res
ngx_var.upstream_uri = res
end
end
end
Expand Down