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

Custom parameters

To make a self-written LuaFilter look more like a regular filter, you should

  • write your script in a separate lua file instead of doing it directly in the web.xml
  • Define a prefix with the "NameSpace" directive in the LuaFilter

Example

filter>
<filter-name>LuaFilter</filter-name>
<filter-class>ch::nevis::isiweb4::filter::lua::LuaFilter</filter-class>
<!-- Declare Naspace for Variables that will be available in the external
Script -->
<init-param>
<param-name>Script.Namespace</param-name>
<param-value>My</param-value>
</init-param>

<init-param>
<param-name>MyFancyParameter</param-name>
<param-value>Something</param-value>
</init-param>
<init-param>
<param-name>Script.OutputFunctionName</param-name>
<param-value>outputStream</param-value>
</init-param>
<init-param>
<param-name>Script.Path</param-name>
<param-value>/path/to/my/script.lua</param-value>
</init-param>
</filter>

The MyFancyParameter is now visible in the /path/to/my/script.lua

function outputStream(req, res, chunk)
if MyFancyParameter ~= nil then
res:setHeader("TestVariable", MyFancyParameter)
end
return chunk
end