in scripts/lua/routing.lua [172:203]
function _M.findResource(dataStore, tenant, path)
local redisKey = utils.concatStrings({"resources:", tenant, ":", path})
local cfRedisKey
local cfUrl = ngx.req.get_headers()["x-cf-forwarded-url"]
if cfUrl ~= nil and cfUrl ~= "" then
local u = url.parse(cfUrl)
cfRedisKey = utils.concatStrings({"resources:", tenant, ":", path, u.path})
ngx.var.analyticsUri = (u.path == "") and "/" or u.path
if next(u.query) ~= nil then
ngx.var.analyticsUri = utils.concatStrings({ngx.var.analyticsUri, '?', u.query})
end
end
local result
if OPTIMIZE > 0 then
result = dataStore:optimizedLookup(tenant, path)
end
if result ~= nil then
ngx.var.gatewayPath = result:gsub(utils.concatStrings({'resources:', tenant, ':'}), '')
return result
end
local resourceKeys = dataStore:getAllResources(tenant)
result = _M.slowLookup(resourceKeys, tenant, path, redisKey, cfRedisKey)
if OPTIMIZE > 0 and result ~= nil then
dataStore:optimizeLookup(tenant, result, path)
end
return result
end