blob: 98f4a9981aa091a9e974e31880e6dcc79a0512f4 [file]
--[[
This wrapper modifies the hostname in the argument passed to the filter handler.
]]
require 'attic_filter'
function output_filter_wrapper(r)
-- copy the variables needed by attic_filter, overriding hostname
-- it's not possible to update hostname in the userdata (r), so we provide a replacment which uses the same syntax
s = {}
-- Copy across the items need by the filter.
s['content_type'] = r.content_type
s['hostname'] = os.getenv('VAR_NAME') or 'localhost'
-- For local debugging, also add the following:
s['warn'] = function(self, txt) r:warn(txt) end
s['info'] = function(self, txt) r:info(txt) end
-- Show that wrapper has been invoked
s:info("Wrapper: " .. s.hostname .. " " .. s.content_type)
output_filter(s) -- call with updated settings
end