add hook for init_by_lua_block
This commit is contained in:
parent
8354478e72
commit
4d92a58349
2 changed files with 16 additions and 6 deletions
12
main.lua
12
main.lua
|
@ -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
|
||||
}
|
||||
|
|
10
nginx.conf
10
nginx.conf
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue