membphis commented on a change in pull request #2132:
URL: https://github.com/apache/apisix/pull/2132#discussion_r479717108
##########
File path: apisix/init.lua
##########
@@ -391,6 +421,7 @@ function _M.http_access_phase()
local enable_websocket
local up_id = route.value.upstream_id
if up_id then
+
Review comment:
we do not need this blank line
##########
File path: apisix/init.lua
##########
@@ -429,6 +460,10 @@ function _M.http_access_phase()
if upstream.value.enable_websocket then
enable_websocket = true
end
+ if upstream.value.pass_host then
Review comment:
need one blank line before `if ... then`
##########
File path: apisix/init.lua
##########
@@ -455,6 +490,10 @@ function _M.http_access_phase()
if route.value.upstream and route.value.upstream.enable_websocket then
enable_websocket = true
end
+ if route.value.upstream and route.value.upstream.pass_host then
Review comment:
ditto
##########
File path: t/node/route-domain.t
##########
@@ -80,3 +80,95 @@ hello world
[error]
--- error_log eval
qr/dns resolver domain: baidu.com to \d+.\d+.\d+.\d+/
+
+
+
+=== TEST 4: set route(id: 1)
+--- config
+ location /t {
+ content_by_lua_block {
+ local t = require("lib.test_admin").test
+ local code, body = t('/apisix/admin/routes/1',
+ ngx.HTTP_PUT,
+ [[{
+ "upstream": {
+ "nodes": {
+ "127.0.0.1:1980": 1
+ },
+ "type": "roundrobin",
+ "pass_host": "rewrite",
+ "upstream_host": "apache.org"
+ },
+ "uri": "/hello"
+ }]]
+ )
+
+ if code >= 300 then
+ ngx.status = code
+ end
+ ngx.say(body)
+ }
+ }
+--- request
+GET /t
+--- response_body
+passed
+--- no_error_log
+[error]
+
+
+
+=== TEST 5: hit routes
+--- request
+GET /hello
+--- error_log
+upstream host mod: rewrite
+set upstream host: apache.org
+--- no_error_log
+[error]
+
+
+
+=== TEST 6: set route(id: 1)
Review comment:
needs a better name too
##########
File path: t/node/route-domain.t
##########
@@ -80,3 +80,95 @@ hello world
[error]
--- error_log eval
qr/dns resolver domain: baidu.com to \d+.\d+.\d+.\d+/
+
+
+
+=== TEST 4: set route(id: 1)
Review comment:
we need a better title
##########
File path: t/node/route-domain.t
##########
@@ -80,3 +80,95 @@ hello world
[error]
--- error_log eval
qr/dns resolver domain: baidu.com to \d+.\d+.\d+.\d+/
+
+
+
+=== TEST 4: set route(id: 1)
+--- config
+ location /t {
+ content_by_lua_block {
+ local t = require("lib.test_admin").test
+ local code, body = t('/apisix/admin/routes/1',
+ ngx.HTTP_PUT,
+ [[{
+ "upstream": {
+ "nodes": {
+ "127.0.0.1:1980": 1
+ },
+ "type": "roundrobin",
+ "pass_host": "rewrite",
+ "upstream_host": "apache.org"
+ },
+ "uri": "/hello"
+ }]]
+ )
+
+ if code >= 300 then
+ ngx.status = code
+ end
+ ngx.say(body)
+ }
+ }
+--- request
+GET /t
+--- response_body
+passed
+--- no_error_log
+[error]
+
+
+
+=== TEST 5: hit routes
Review comment:
change to `hit route` is better, only one route here
##########
File path: t/node/upstream.t
##########
@@ -262,3 +262,150 @@ GET /t
[delete] code: 404
--- no_error_log
[error]
+
+
+
+=== TEST 11: set upstream(id: 1) nodes
Review comment:
need a better name
##########
File path: apisix/schema_def.lua
##########
@@ -332,6 +332,12 @@ local upstream_schema = {
description = "enable websocket for request",
type = "boolean"
},
+ pass_host = {
+ description = "mod of host passing",
+ type = "string",
+ enum = {"pass", "node", "rewrite"}
Review comment:
set default value `pass`
----------------------------------------------------------------
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]