Skip to content

Commit

Permalink
clean fill_atc_context
Browse files Browse the repository at this point in the history
  • Loading branch information
chronolaw committed Feb 26, 2024
1 parent afd81ce commit 6a85e8b
Showing 1 changed file with 18 additions and 22 deletions.
40 changes: 18 additions & 22 deletions kong/router/fields.lua
Original file line number Diff line number Diff line change
Expand Up @@ -401,30 +401,26 @@ end


local function visit_for_context(field, value, ctx)
local prefix = field:sub(1, PREFIX_LEN)

if prefix == HTTP_HEADERS_PREFIX or prefix == HTTP_QUERIES_PREFIX then
local v_type = type(value)

-- multiple values for a single query parameter, like /?foo=bar&foo=baz
if v_type == "table" then
for _, v in ipairs(value) do
local res, err = ctx:add_value(field, v)
if not res then
return nil, err
end
local v_type = type(value)

-- multiple values for a single header/query parameter, like /?foo=bar&foo=baz
if v_type == "table" then
for _, v in ipairs(value) do
local res, err = ctx:add_value(field, v)
if not res then
return nil, err
end

return true
end -- if v_type

-- the query parameter has only one value, like /?foo=bar
-- the query parameter has no value, like /?foo,
-- get_uri_arg will get a boolean `true`
-- we think it is equivalent to /?foo=
if v_type == "boolean" then
value = ""
end

return true
end -- if v_type

-- the header/query parameter has only one value, like /?foo=bar
-- the query parameter has no value, like /?foo,
-- get_uri_arg will get a boolean `true`
-- we think it is equivalent to /?foo=
if v_type == "boolean" then
value = ""
end

return ctx:add_value(field, value)
Expand Down

0 comments on commit 6a85e8b

Please sign in to comment.