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): move assert to unlikely path #12466

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


-- stream subsystem need not to generate func
local get_field_accessor = function(funcs, field) end
-- stream subsystem needs not to generate func
local function get_field_accessor(funcs, field)
error("unknown router matching schema field: " .. field)
end


if is_http then
Expand Down Expand Up @@ -359,7 +361,8 @@ if is_http then
return f
end -- if field:sub(1, HTTP_SEGMENTS_PREFIX_LEN)

-- others return nil
-- others are error
error("unknown router matching schema field: " .. field)
end

end -- is_http
Expand Down Expand Up @@ -451,8 +454,6 @@ function _M:get_value(field, params, ctx)
local func = FIELDS_FUNCS[field] or
get_field_accessor(self.funcs, field)

assert(func, "unknown router matching schema field: " .. field)

return func(params, ctx)
end

Expand Down
Loading