OpenResty - LUA module
by
Jeremy Canfield |
Updated: July 15 2021
| OpenResty articles
This assumes you have installed OpenResty on a Linux system.
Let's say you have a module named core.lua that contains the following.
local _foo = {}
function _foo.hello() print("Hello") end
function _foo.world() print("World") end
return _foo
The resty command can be used to invoke the core.lua module. If the core.lua module is in your present working directory, here is how you would invoke the "hello" function.
~]# resty -e 'require "core".hello()'
Hello
Or the "world" function.
~]# resty -e 'require "core".world()'
World
If core.lua is not in your present working directory, the -I option can be used to point to the directory that contains core.lua.
~]# resty -I /usr/local/share/lua -e 'require "core".hello()'
Hello
Did you find this article helpful?
If so, consider buying me a coffee over at