你说的加载具体是指哪一部分,下面是从外部文件加载的函数,以及外部文件的内容
local function load_static_tokens()
local file, err = io.open(config.static_tokens.file_path, "r")
if not file then
ngx.log(ngx.WARN, "static token file not found or could not be opened: ", config.static_tokens.file_path, " | error: ", err)
return false
end
local content = file:read("*a")
file:close()
local ok, data = pcall(cjson.decode, content)
if not ok or type(data) ~= "table" then
ngx.log(ngx.ERR, "failed to decode static token file: ", config.static_tokens.file_path, " | error: ", tostring(data))
return false
end
_M.static_tokens = data
local count = 0
for _ in pairs(_M.static_tokens) do count = count + 1 end
ngx.log(ngx.INFO, "successfully loaded/reloaded ", count, " static tokens from file: ", config.static_tokens.file_path)
return true
end
cat static_tokens.json
{
"e945d7d9-9e6e-4721-922a-7251a9d321d0-1678159756805": "internal",
"c5e6d492-baed-40bf-9b27-93119d2d3a0d-1689232838129": "internal"