Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(router/atc): simplify searching for field accessor function #12664

Merged
merged 1 commit into from
Feb 29, 2024
Merged
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
10 changes: 7 additions & 3 deletions kong/router/fields.lua
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ end -- is_http

-- stream subsystem needs not to generate func
local function get_field_accessor(funcs, field)
local f = FIELDS_FUNCS[field]
if f then
return f
end

error("unknown router matching schema field: " .. field)
end

Expand Down Expand Up @@ -259,7 +264,7 @@ if is_http then


get_field_accessor = function(funcs, field)
local f = funcs[field]
local f = FIELDS_FUNCS[field] or funcs[field]
if f then
return f
end
Expand Down Expand Up @@ -447,8 +452,7 @@ end


function _M:get_value(field, params, ctx)
local func = FIELDS_FUNCS[field] or
get_field_accessor(self.funcs, field)
local func = get_field_accessor(self.funcs, field)

return func(params, ctx)
end
Expand Down
Loading