membphis commented on a change in pull request #2132:
URL: https://github.com/apache/apisix/pull/2132#discussion_r479735530



##########
File path: apisix/admin/upstreams.lua
##########
@@ -80,7 +80,7 @@ local function check_upstream_conf(conf)
 
     -- only support single node for `node` mode currently
     if conf.pass_host == "node" and conf.nodes and #conf.nodes > 1 then

Review comment:
       I think `#conf.nodes ~= 1` is better for current case

##########
File path: apisix/admin/upstreams.lua
##########
@@ -80,7 +80,7 @@ local function check_upstream_conf(conf)
 
     -- only support single node for `node` mode currently
     if conf.pass_host == "node" and conf.nodes and #conf.nodes > 1 then
-        return false, "only support single node for `node` mode currently."
+        return false, "only support single node for `node` mode currently"

Review comment:
       need test case

##########
File path: apisix/init.lua
##########
@@ -299,34 +299,38 @@ end
 
 
 local function set_upstream_host(api_ctx)
-    local pass_host = api_ctx.pass_host
-    if pass_host and pass_host ~= "pass" then
-        local host
-        -- only support single node for `node` mode currently
-        if pass_host == "node" then
-            core.log.info("upstream host mod: node")
-            local up_conf = api_ctx.upstream_conf
-            local nodes_count = up_conf.nodes and #up_conf.nodes or 0
-            if nodes_count == 1 then
-                local node = up_conf.nodes[1]
-                if node.domain and #node.domain > 0 then
-                    host = node.domain
-                else
-                    host = node.host
-                end
-            end
-        elseif pass_host == "rewrite" then
-            core.log.info("upstream host mod: rewrite")
-            host = api_ctx.upstream_host and api_ctx.upstream_host
-        end
+    local pass_host = api_ctx.pass_host or "pass"
+    if pass_host == "pass" then
+        return
+    end
 
+    local host
+    if pass_host == "rewrite" then

Review comment:
       this style is simpler.
   
   ```lua
   if pass_host == "rewrite" then
       api_ctx.var.upstream_host = api_ctx.upstream_host
       retturn
   end




----------------------------------------------------------------
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:
[email protected]


Reply via email to