bugfix: used a single option as the apisix configuration prefix name.

This commit is contained in:
Yuansheng Wang 2019-06-05 14:21:25 +08:00
parent 80dc33e86e
commit 8cea2c66d7
4 changed files with 15 additions and 9 deletions

View File

@ -28,7 +28,7 @@ apisix:
etcd:
host: "http://127.0.0.1:2379" # etcd address
prefix: "/v2/keys/apisix" # etcd prefix
prefix: "apisix" # apisix configurations prefix
timeout: 60
plugins: # plugin name list
@ -41,11 +41,13 @@ plugins: # plugin name list
*注意* 不要手工修改 Apisix 自身的 `conf/nginx.conf` 文件,当服务每次启动时,`apisix`
会根据 `conf/config.yaml` 配置自动生成新的 `conf/nginx.conf` 并自动启动服务。
目前读写 `etcd` 操作使用的是 v2 协议,所有配置均存储在 `/v2/keys` 目录下。
[Back to TOC](#summary)
## Route
默认路径:`/v2/keys/apisix/routes/****`
默认路径:`/apisix/routes/****`
`Route` 是如何匹配用户请求的具体描述。目前 Apisix 支持 `URI``Method` 两种方式匹配
用户请求。其他比如 `Host` 方式,将会持续增加。

View File

@ -234,9 +234,10 @@ local function init_etcd(show_output)
end
local etcd_conf = yaml_conf.etcd
local uri = etcd_conf.host .. etcd_conf.prefix
local uri = etcd_conf.host .. "/v2/keys" .. (etcd_conf.prefix or "")
for _, dir_name in ipairs({"/routes", "/upstreams", "/services"}) do
for _, dir_name in ipairs({"/routes", "/upstreams", "/services",
"/plugins", "/consumers"}) do
local cmd = "curl " .. uri .. dir_name
.. "?prev_exist=false -X PUT -d dir=true 2>&1"
local res = exec(cmd)

View File

@ -3,7 +3,7 @@ apisix:
etcd:
host: "http://127.0.0.1:2379" # etcd address
prefix: "/v2/keys/apisix" # etcd prefix
prefix: "/apisix" # apisix configurations prefix
timeout: 60
plugins: # plugin name list

View File

@ -232,6 +232,9 @@ function _M.new(key, opts)
return nil, err
end
local prefix = local_conf.etcd.prefix
local_conf.etcd.prefix = nil
local etcd_cli
etcd_cli, err = etcd.new(local_conf.etcd)
if not etcd_cli then
@ -242,14 +245,14 @@ function _M.new(key, opts)
local obj = setmetatable({
etcd_cli = etcd_cli,
values = nil,
routes_hash = nil,
prev_index = nil,
key = key,
key = key and prefix .. key,
automatic = automatic,
sync_times = 0,
running = true,
conf_version = 0,
values = nil,
routes_hash = nil,
prev_index = nil,
last_err = nil,
last_err_time = nil,
}, mt)