You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2021/05/05 09:56:05 UTC

[GitHub] [apisix] tzssangglass commented on a change in pull request #4121: feat: support to use upstream_id in stream_route

tzssangglass commented on a change in pull request #4121:
URL: https://github.com/apache/apisix/pull/4121#discussion_r623531458



##########
File path: apisix/init.lua
##########
@@ -279,6 +280,38 @@ local function set_upstream_host(api_ctx)
 end
 
 
+local function get_upstream_by_id(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)
+            if is_http then
+                return core.response.exit(502)
+            end
+
+            return ngx_exit(1)
+        end
+
+        if upstream.has_domain then
+            local err
+            upstream, err = parse_domain_in_up(upstream)
+            if err then
+                core.log.error("failed to get resolved upstream: ", err)
+                if is_http then
+                    return core.response.exit(500)

Review comment:
       origin code return 500 http status code




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org