Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apisix/core/config_yaml.lua
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ end


function _M.fetch_created_obj(key)
return created_obj[key]
return created_obj[sub_str(key, 2)]
end


Expand Down
11 changes: 8 additions & 3 deletions apisix/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,14 @@ function _M.http_access_phase()
local enable_websocket
local up_id = route.value.upstream_id
if up_id then
local upstreams_etcd = core.config.fetch_created_obj("/upstreams")
if upstreams_etcd then
local upstream = upstreams_etcd:get(tostring(up_id))
local upstreams = core.config.fetch_created_obj("/upstreams")
if upstreams then
local upstream = upstreams:get(tostring(up_id))
if not upstream then
core.log.error("failed to find upstream by id: " .. up_id)
return core.response.exit(500)
end

if upstream.has_domain then
local _, err = parsed_domain(upstream, api_ctx.conf_version,
parse_domain_in_up, upstream)
Expand Down
22 changes: 22 additions & 0 deletions t/config-center-yaml/route-upstream.t
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,25 @@ GET /hello
hello world
--- no_error_log
[error]



=== TEST 5: upstream domain
--- yaml_config eval: $::yaml_config
--- apisix_yaml
routes:
-
uri: /get
upstream_id: 1
upstreams:
-
id: 1
nodes:
"httpbin.org:80": 1
type: roundrobin
#END
--- request
GET /get
--- error_code: 200
--- no_error_log
[error]