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()) ctx:loadFromConfig(config.loadConfigFile())
return function() return {
init=function ()
-- validate config and print out errors
config.loadConfigFile()
end,
access=function()
ctx:onRequest() ctx:onRequest()
end end
}

View File

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