OpenResty - LUA module

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 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()'


Or the "world" function.

~]# resty -e 'require "core".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()'


Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee

Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

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


Web design by yours truely - me, myself, and I   |   |