let filters customize status code and body
This commit is contained in:
parent
a747fe8182
commit
06924d10f6
1 changed files with 5 additions and 7 deletions
12
main.lua
12
main.lua
|
@ -43,14 +43,12 @@ local function onRequest()
|
||||||
log('AWOOOOGA')
|
log('AWOOOOGA')
|
||||||
|
|
||||||
for _,tuple in ipairs(callbacks_to_call) do
|
for _,tuple in ipairs(callbacks_to_call) do
|
||||||
local callback_function, config = tuple[1], tuple[2]
|
local callback_function, config, state = unpack(tuple)
|
||||||
local result, body = callback_function(config)
|
local status_code, body = callback_function(config, state)
|
||||||
log(result)
|
if status_code ~= nil then
|
||||||
log(body)
|
ngx.status = status_code
|
||||||
if not result then
|
|
||||||
ngx.status = 400
|
|
||||||
ngx.say(body or "request denied")
|
ngx.say(body or "request denied")
|
||||||
ngx.exit(400)
|
ngx.exit(status_code)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue