Skip to content

Commit

Permalink
clean fill_atc_context
Browse files Browse the repository at this point in the history
  • Loading branch information
chronolaw authored and kikito committed Feb 27, 2024
1 parent af21761 commit 11f6b56
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 @@ -404,30 +404,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

1 comment on commit 11f6b56

@gszr
Copy link
Member

@gszr gszr commented on 11f6b56 Feb 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commit message out of the convention.

Please sign in to comment.