add hook for init_by_lua_block

This commit is contained in:
Luna 2022-12-07 15:40:48 -03:00
parent 8354478e72
commit 4d92a58349
2 changed files with 16 additions and 6 deletions

View File

@ -12,6 +12,12 @@ require('util')
ctx:loadFromConfig(config.loadConfigFile())
return function()
ctx:onRequest()
end
return {
init=function ()
-- validate config and print out errors
config.loadConfigFile()
end,
access=function()
ctx:onRequest()
end
}

View File

@ -1,4 +1,8 @@
server {
init_by_lua_block {
require("aproxy.main").init()
}
server {
listen 80;
lua_code_cache off;
@ -7,9 +11,9 @@
# must happen before proxy_pass
access_by_lua_block {
require("aproxy.main")()
require("aproxy.main").access()
}
proxy_pass http://localhost:9999;
}
}
}