Replies: 1 comment 1 reply
-
谢谢,已经解决。 用core.etcd.get(lc_etcd_key)替换了core.config.fetch_created_obj(config_path) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
local saas_infos = core.config.fetch_created_obj(config_path)
重启后拿不回来etcd里的数据
local ngx = ngx
local plugin = require("apisix.plugin")
local core = require("apisix.core")
local upstream = require("apisix.upstream")
local plugin_name = "saas-route"
local schema = {
type = "object",
properties = {
deny_on_mismatch = {type = "boolean", default = false} ,
header_name = {type = "string", default = "saas_code"} ,
}
}
local _M = {
version = 0.1,
priority = 0,
name = plugin_name,
schema = schema ,
}
local saas_schema = {type="object",properties={saas_code={type="string"},upstream_id={type="string"} } }
local config_path
local config_obj
function _M.check_schema(conf, schema_type)
if schema_type == core.schema.TYPE_METADATA then
return core.schema.check(metadata_schema, conf)
end
return core.schema.check(schema, conf)
end
function _M.init()
local local_conf = core.config.local_conf()
-- config_path = core.table.try_read_attr(local_conf, plugin_name, "config_path")
-- config_path = "/config_path"
end
function _M.destroy()
-- call this function when plugin is unloaded
end
function _M.rewrite(conf, ctx)
end
function _M.access(conf, ctx)
local header_name = conf.header_name
local saas_code = core.request.header(ctx,header_name)
if not saas_code then
saas_code = core.request.get_uri_args(ctx)[header_name]
end
end
local function check_token(ctx)
local local_conf = core.config.local_conf()
if not local_conf or not local_conf.apisix
or not local_conf.apisix.admin_key then
return true
end
end
local function set_saas_dict(ctx)
local args = core.request.get_uri_args(ctx)
if not args.saas_code or not args.upstream_id then
return 200, {msg = "invalid args"}
end
end
local function get_saas_dict(ctx)
local ok, err = check_token(ctx)
if not ok then
core.log.warn("failed to check token: ", err)
return 401
end
end
function _M.api()
return {
{ methods = { "POST" },uri = "/apisix/plugin/saas-route/set",handler = set_saas_dict,},
{ methods = { "GET" },uri = "/apisix/plugin/saas-route/get",handler = get_saas_dict,},
}
end
return _M
local saas_infos = core.config.fetch_created_obj(config_path)
重启后拿不回来etcd里的数据
Beta Was this translation helpful? Give feedback.
All reactions