Skip to content

Commit

Permalink
style get_http_segments
Browse files Browse the repository at this point in the history
  • Loading branch information
chronolaw committed Jan 24, 2024
1 parent 5ef8012 commit 3d715fa
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions kong/router/fields.lua
Original file line number Diff line number Diff line change
Expand Up @@ -210,17 +210,21 @@ if is_http then

local HTTP_SEGMENTS_PREFIX = "http.path.segments."
local HTTP_SEGMENTS_PREFIX_LEN = #HTTP_SEGMENTS_PREFIX
local HTTP_SEGMENTS_REG_CTX = { pos = 2, } -- skip first '/'
local HTTP_SEGMENTS_OFFSET = 1


local function get_http_segments(params)
if not params.segments then
HTTP_SEGMENTS_REG_CTX.pos = 2 -- reset ctx, skip first '/'
params.segments = re_split(params.uri, "/", "jo", HTTP_SEGMENTS_REG_CTX)
end
local get_http_segments
do
local HTTP_SEGMENTS_REG_CTX = { pos = 2, } -- skip first '/'

get_http_segments = function(params)
if not params.segments then
HTTP_SEGMENTS_REG_CTX.pos = 2 -- reset ctx, skip first '/'
params.segments = re_split(params.uri, "/", "jo", HTTP_SEGMENTS_REG_CTX)
end

return params.segments
return params.segments
end
end


Expand Down

0 comments on commit 3d715fa

Please sign in to comment.