Skip to content

Commit

Permalink
lol
Browse files Browse the repository at this point in the history
  • Loading branch information
shreemaan-abhishek committed Aug 24, 2023
1 parent e803be2 commit 36e6b85
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
17 changes: 8 additions & 9 deletions conf/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,11 @@
#
# This will find environment variable `ETCD_HOST` first, and if it's not exist it will use `localhost` as default value.
#
deployment:
role: traditional
role_traditional:
config_provider: etcd
admin:
admin_key:
- name: admin
key: edd1c9f034335f136f87ad84b625c8f1 # using fixed API token has security risk, please update it when you deploy to production environment
role: admin
apisix:
proxy_mode: http&stream
extra_lua_path: "\$prefix/example/?.lua"
lua_module_hook: "my_hook"
stream_proxy:
tcp:
- addr: 9100

8 changes: 8 additions & 0 deletions example/my_hook.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,22 @@
--
local apisix = require("apisix")

local fun = function()
require("apisix.core").ctx.register_var("lol", function(ctx)
return "haha"
end)
end

local old_http_init = apisix.http_init
apisix.http_init = function (...)
fun()
ngx.log(ngx.EMERG, "my hook works in http")
old_http_init(...)
end

local old_stream_init = apisix.stream_init
apisix.stream_init = function (...)
fun()
ngx.log(ngx.EMERG, "my hook works in stream")
old_stream_init(...)
end

0 comments on commit 36e6b85

Please sign in to comment.