Skip to content

Commit

Permalink
support any() in header matches
Browse files Browse the repository at this point in the history
  • Loading branch information
dndx committed Jun 15, 2022
1 parent f7e340a commit d80edcb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions kong/router/atc_compat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ local function get_atc(route)
for h, v in pairs(route.headers) do
local single_header = {}
for _, ind in ipairs(v) do
local name = "http.headers." .. h:gsub("-", "_"):lower()
local name = "any(http.headers." .. h:gsub("-", "_"):lower() .. ")"
local value = ind
local op = "=="
if ind:sub(1, 2) == "~*" then
Expand Down Expand Up @@ -471,8 +471,9 @@ function _M:select(req_method, req_uri, req_host, req_scheme,
assert(c:add_value(field, v:lower()))

else
-- TODO: support array of values
assert(c:add_value(field, v[1]:lower()))
for _, v in ipairs(v) do
assert(c:add_value(field, v:lower()))
end
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/01-unit/08-router_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1508,7 +1508,7 @@ for _, flavor in ipairs({ "traditional", "traditional_compatible" }) do
end)

describe("[headers]", function()
it_trad_only("evaluates Routes with more [headers] first", function()
it("evaluates Routes with more [headers] first", function()
local use_case = {
{
service = service,
Expand Down

0 comments on commit d80edcb

Please sign in to comment.