From 047f6290eabdaec6a44c9e1fdebf33e4c6002d59 Mon Sep 17 00:00:00 2001 From: jinhua luo Date: Fri, 9 Sep 2022 17:27:38 +0800 Subject: [PATCH] feat: set constants.apisix_lua_home for used by plugins (#7893) --- apisix/cli/ngx_tpl.lua | 5 +++++ t/APISIX.pm | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/apisix/cli/ngx_tpl.lua b/apisix/cli/ngx_tpl.lua index fa7bfc9bb4ed..5d814a091e4e 100644 --- a/apisix/cli/ngx_tpl.lua +++ b/apisix/cli/ngx_tpl.lua @@ -432,6 +432,11 @@ http { dns_resolver = dns_resolver, } apisix.http_init(args) + + -- set apisix_lua_home into constans module + -- it may be used by plugins to determine the work path of apisix + local constants = require("apisix.constants") + constants.apisix_lua_home = "{*apisix_lua_home*}" } init_worker_by_lua_block { diff --git a/t/APISIX.pm b/t/APISIX.pm index 26bf7efe66ce..070733c28708 100644 --- a/t/APISIX.pm +++ b/t/APISIX.pm @@ -490,6 +490,12 @@ _EOC_ dns_resolver = $dns_addrs_tbl_str, } apisix.http_init(args) + + -- set apisix_lua_home into constans module + -- it may be used by plugins to determine the work path of apisix + local constants = require("apisix.constants") + constants.apisix_lua_home = "$apisix_home" + $extra_init_by_lua _EOC_