Global Lua Modules

Global Lua modules provide a powerful mechanism for implementing complex logical functionalities. Unlike YAML configuration files, global Lua modules use the .lua file extension and must be placed in a subdirectory called global_lua_modules within the configuration directory.


Create a Lua module named hello.lua:

local _M = {}

function _M.go()

return _M

Invoke the hello Lua module in the page rules:

- enable_rule: true
      el: |-
        true =>
            foreign-call(module: "hello", func: "go"),
  comment: ''

In the above example, a simple Lua module hello.lua contains a function named go that outputs “hello”. Then, in the page rule configuration, this module and function are invoked through the expression.