a.lua和b.lua在同一个目录下
a.lua调用b.lua中的test方法,注意b中test的写法 _M 和 a中调用方法:
b.lua
local _M = {}
function _M.test()
ngx.say("hello test!")
end
return _M
a.lua
local test = require("b")
if not test then
ngx.say("Failed to require b!")
return
end
test:test()
/openresty/lualib/resty里面的写法可参考