show name of module that filtered request in logs

This commit is contained in:
Luna 2022-12-07 01:49:00 -03:00
parent 0c0b842370
commit fb43b80e6b
1 changed files with 4 additions and 3 deletions

View File

@ -34,15 +34,16 @@ function ctx:onRequest()
for callback_regex, callback_function in pairs(module.callbacks) do
local match, error = ngx.re.match(request_uri, callback_regex)
if match then
table.insert(callbacks_to_call, {callback_function, module_config, state})
table.insert(callbacks_to_call, {module, callback_function, module_config, state})
end
end
end
for _,tuple in ipairs(callbacks_to_call) do
local callback_function, config, state = unpack(tuple)
for _, tuple in ipairs(callbacks_to_call) do
local module, callback_function, config, state = unpack(tuple)
local status_code, body = callback_function(config, state)
if status_code ~= nil then
log('filtered by module ' .. module.name)
ngx.status = status_code
ngx.say(body or "request denied")
ngx.exit(status_code)