in pluginats/connect_redis.lua [43:88]
function check_path_prefix_match(req_scheme, req_host, req_path)
local host_path = "P+"..req_scheme .. "://" .. req_host .. req_path
ts.debug('checking host_path: '..host_path)
client:select(1)
local svcs = client:smembers(host_path)
if (svcs ~= nil and #svcs > 0) then
return svcs
end
local t = {}
local i = 0
while true do
i = string.find(req_path, "%/", i+1)
if i == nil then break end
table.insert(t, i)
end
for index = #t, 1, -1 do
local pathindex = t[index]
local subpath = string.sub (req_path, 1, pathindex)
host_path = "P+"..req_scheme .. "://" .. req_host .. subpath
ts.debug('checking host_path: '..host_path)
client:select(1)
svcs =client:smembers(host_path)
if (svcs ~= nil and #svcs > 0) then
return svcs
end
if pathindex > 1 then
subpath = string.sub (req_path, 1, pathindex - 1)
host_path = "P+"..req_scheme .. "://" .. req_host .. subpath
ts.debug('checking host_path: '..host_path)
client:select(1)
svcs = client:smembers(host_path)
if (svcs ~= nil and #svcs > 0) then
return svcs
end
end
end
return nil
end