load lua plugins and actions
load file as lua plugin
the file containing the lua code
A key-value table with options; no options available yet
arguments forwarded to the lua plugin
A lua plugin can register setup and action callbacks (like any C module) by creating a setups / actions table in the global lua namespace.
The filename and the third argument @lua-args@ are available as parameters in @...@ in the lua script.
setup {
module_load "mod_lua";
lua.plugin "secdownload.lua";
}
(see "contrib/core.lua":http://git.lighttpd.net/lighttpd/lighttpd2.git/tree/contrib/core.lua for a real example)
local filename, args = ...
-- args are from the lua.plugin line
local function simple(actionarg)
-- actionarg is the parameter from the 'single "/xxx";' action line
-- create an action:
return action.respond()
end
actions = {
["simple"] = simple,
}
load file as lua config
the file containing the lua code
time in seconds after which the file is checked for modifications and reloaded. 0 disables reloading (default 0)
arguments forwarded to the lua plugin
lua.handler is basically the same as "include_lua":core_config.html#core_config__includes with the following differences:
* each worker loads the lua file itself
* it isn't loaded before it is used, so you won't see errors in the script at load time
* it cannot call setup functions
* it supports arguments to the script (@local filename, args = ...@)
* doesn't lock the global lua lock, so it performs better when you use multiple workers
See "contrib/core.lua":http://git.lighttpd.net/lighttpd/lighttpd2.git/tree/contrib/core.lua for how we load some external actions like "contrib/core__xsendfile.lua":http://git.lighttpd.net/lighttpd/lighttpd2.git/tree/contrib/core__xsendfile.lua
setup {
module_load "mod_lua";
lua.plugin "secdownload.lua";
}
if req.path =^ "/app" {
lua.handler "/etc/lighttpd/pathrewrite.lua", [ "ttl" => 300 ], "/app";
}