-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how to use require? #14
Comments
This is more like a Lua question. To understand why this happens, see http://www.lua.org/manual/5.1/manual.html#pdf-require To quote the key sentence: "The (require) function starts by looking into the package.loaded table to determine whether modname is already loaded. If it is, then require returns the value stored at package.loaded[modname]. Otherwise, it tries to find a loader for the module. " That is, Lua's "require" will not re-load a module for the sake of performance. So you're coding up Lua modules in a totally wrong way. We usually use Lua modules this way instead:
And then in your content_by_lua_file directive's lua file:
You will see the "test.lua" output on every request as you'd expect. |
thank you!! |
i use require like:
local xxx = require('xxx')
but,it also haven't to work.
--test.lua
function a()
ngx.print("test.lua");
end;
a();
--concat.lua
local test=require("test");
at the first request,it print:
test.lua
and,the next time,have nothing print;
The text was updated successfully, but these errors were encountered: