Skip to main content
Version: 7.2402.x.x RR

LuaFilter - introduction

The LuaFilter can be used for advanced rewriting of body data and/or headers of request and/or response. For more details about Lua itself, see http://www.lua.org/manual/5.3/.

A sample Lua script should visualize the idea:

function output(request, response, chunk)
if chunk == nil then
return "hello world"
end
end

The Script.OutputFunctionName parameter must be "output". For every chunk of data from the back end the script is called. The nil chunk marks the end of the stream. The sample script replaces the response body with "hello world". Beside the body data there are two objects "request" and "response" (of course you can name this different). With these two objects, you access headers, environment variables and attributes.

The LuaFilter can call a Lua function that is defined in the init parameter Script.OutputHeaderFunctionName. This function will be called once for every response before the body data, and can be used to add/set header attributes. Example Lua script:

function outputHeader(req, resp)
resp:setHeader("outputHeader","called")
end

Classname

ch::nevis::isiweb4::filter::lua::LuaFilter

Library

libLuaFilter.so.1