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/04/02 09:39:40 UTC
[GitHub] [apisix] Firstsawyou commented on a change in pull request #3556: feat: support rewrite HTTP method
Firstsawyou commented on a change in pull request #3556:
URL: https://github.com/apache/apisix/pull/3556#discussion_r606161255
##########
File path: t/plugin/proxy-rewrite.t
##########
@@ -1370,3 +1370,100 @@ host: test.com:6443
x-real-ip: 127.0.0.1
--- no_error_log
[error]
+
+
+
+=== TEST 47: set route(rewrite HTTP method)
+--- 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,
+ [[{
+ "methods": ["GET"],
+ "plugins": {
+ "proxy-rewrite": {
+ "method": "POST"
+ }
+ },
+ "upstream": {
+ "nodes": {
+ "127.0.0.1:1980": 1
+ },
+ "type": "roundrobin"
+ },
+ "uri": "/hello"
Review comment:
Hi, @54corbin
You can modify the corresponding test file according to the content of `diff` here.
```shell
diff --git a/t/lib/server.lua b/t/lib/server.lua
index 4e96223..700a439 100644
--- a/t/lib/server.lua
+++ b/t/lib/server.lua
@@ -80,6 +80,7 @@ function _M.plugin_proxy_rewrite()
ngx.say("uri: ", ngx.var.uri)
ngx.say("host: ", ngx.var.host)
ngx.say("scheme: ", ngx.var.scheme)
+ ngx.say("method: ", ngx.var.request_method)
end
diff --git a/t/plugin/proxy-rewrite.t b/t/plugin/proxy-rewrite.t
index ca760a0..0aaeffa 100644
--- a/t/plugin/proxy-rewrite.t
+++ b/t/plugin/proxy-rewrite.t
@@ -250,6 +250,7 @@ GET /hello HTTP/1.1
uri: /plugin_proxy_rewrite
host: apisix.iresty.com
scheme: http
+method: GET
--- no_error_log
[error]
@@ -303,6 +304,7 @@ GET /hello HTTP/1.1
uri: /plugin_proxy_rewrite
host: test.com
scheme: https
+method: GET
--- no_error_log
[error]
@@ -675,6 +677,7 @@ GET /test/plugin/proxy/rewrite HTTP/1.1
uri: /plugin_proxy_rewrite
host: localhost
scheme: http
+method: GET
--- no_error_log
[error]
@@ -1384,6 +1387,7 @@ x-real-ip: 127.0.0.1
"methods": ["GET"],
"plugins": {
"proxy-rewrite": {
+ "uri": "/plugin_proxy_rewrite",
"method": "POST"
}
},
@@ -1416,7 +1420,10 @@ passed
--- request
GET /hello
--- response_body
-hello world
+uri: /plugin_proxy_rewrite
+host: localhost
+scheme: http
+method: POST
--- error_log eval
qr/changed HTTP method from GET to POST/
@@ -1432,6 +1439,7 @@ qr/changed HTTP method from GET to POST/
[[{
"plugins": {
"proxy-rewrite": {
+ "uri": "/plugin_proxy_rewrite",
"method": "PUT"
}
},
@@ -1460,10 +1468,13 @@ passed
-=== TEST 50: rewrite HTTP method (GET to PUT)
---- request
+=== TEST 50: rewrite HTTP method (GET to PUT)
+--- request
GET /hello
--- response_body
-hello world
+uri: /plugin_proxy_rewrite
+host: localhost
+scheme: http
+method: PUT
--- error_log eval
qr/changed HTTP method from GET to PUT/
diff --git a/t/plugin/proxy-rewrite2.t b/t/plugin/proxy-rewrite2.t
index 5045792..57e6ee0 100644
--- a/t/plugin/proxy-rewrite2.t
+++ b/t/plugin/proxy-rewrite2.t
@@ -104,3 +104,4 @@ serverless []
uri: /plugin_proxy_rewrite
host: localhost
scheme: http
+method: GET
```
--
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