如何在同一位置 = /_sample 下添加多个 access_by_lua_file 指令

在位置下使用 openidc 模块内省,并使用以下方法调用,

策略部分
#
location = /_sample {
    internal;
    set $api_name "sample";
    access_by_lua_file /etc/nginx/path/oauth_introspection.lua;
     Proxypass......
}

现在我想在同一请求下包含下面的 lua 文件以添加一些内容并验证一些内容。

策略部分
#
location = /_sample {
    internal;
    set $api_name "sample";
    access_by_lua_file /etc/nginx/path/oauth_introspection.lua;
        access_by_lua_file /etc/nginx/path/do_something.lua; // 重复引发错误
     Proxypass......
}

我的 oauth_introspection.lua 文件具有以下 openidc introspect 逻辑,

local res, err = require("resty.openidc").introspect(opts)
点赞
用户12918181
用户12918181

access_by_lua_file 只能使用一次。您必须将代码合并到 lua 文件中:

location = /_sample {
    internal;
    set $api_name "sample";
    access_by_lua_file /etc/nginx/path/action_sample.lua;
    Proxypass......
}

action_sample.lua:

local res, err = require("resty.openidc").introspect(opts)

-- 做一些事情或
loadfile("/etc/nginx/path/do_something.lua")(opts)
2020-03-08 22:18:42