Skip to main content
Version: 3.14.x.x LTS

Lua internal modules

The internal Lua modules are created and supported by AdNovum. Each of these modules contains a collection of functions for different purposes. The main goal of each module is to write compact, more readable and error-safe Lua scripts.

The following internal modules are available:

  • Encoders - Helper module for URL and HTML encoding.
  • Utils - Provides a collection of useful functions mainly used for modifying (and parsing) request/response headers, queries and cookies.
  • Helpers - Offers a collection of useful string functions.
  • GlobalStore - Global facility to store data across instances, by using a MySqlSessionStoreServlet.
  • Multipart - Public interface for reading parts in a multi-part request body.

If you want to use one or more of the modules, first set the pacakge.path variable, so that the script can load the module(s). The loading of the modules happens with the require keyword, followed by the name of the module.

The following example shows how to use an internal Lua module:

package.path = package.path .. ";/opt/nevisproxy/webapp/WEB-INF/lib/lua/public/?.lua" -- setting the path
Utils = require "Utils" -- loading the module

function inputHeader(req, resp)
local cookies = Utils.parseCookieHeader(req) -- using the module
for name, value in pairs(cookies) do
print(name, value)
end
end

The internal Lua modules can be found in the shipped package, in the folder "../lib/lua/public/".

Be aware that only Lua modules in the public folder are supported and will stay backward-compatible.