Bootstrap FreeKB - OpenResty - LUA module
OpenResty - LUA module

Updated:   |  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 Buy Me A Coffee



Comments


Add a Comment


Please enter 40381e in the box below so that we can be sure you are a human.