starsz commented on a change in pull request #3556:
URL: https://github.com/apache/apisix/pull/3556#discussion_r634482828
##########
File path: apisix/plugins/proxy-rewrite.lua
##########
@@ -178,6 +183,44 @@ function _M.rewrite(conf, ctx)
ctx.var.upstream_uri = upstream_uri
end
+ -- enum = {"GET", "POST", "PUT", "DELETE", "PATCH", "HEAD","OPTIONS",
"CONNECT", "TRACE"}
+ -- change HTTP method
+ if conf.method ~= nil then
+
+ if conf.method == "GET" then
+ ngx.req.set_method(ngx.HTTP_GET)
+
+ elseif conf.method == "POST" then
+ ngx.req.set_method(ngx.HTTP_POST)
+
+ elseif conf.method == "PUT" then
+ ngx.req.set_method(ngx.HTTP_PUT)
+
+ elseif conf.method == "DELETE" then
+ ngx.req.set_method(ngx.HTTP_DELETE)
+
+ elseif conf.method == "PATCH" then
+ ngx.req.set_method(ngx.HTTP_PATCH)
+
+ elseif conf.method == "HEAD" then
+ ngx.req.set_method(ngx.HTTP_HEAD)
+
+ elseif conf.method == "OPTIONS" then
+ ngx.req.set_method(ngx.HTTP_OPTIONS)
+
+ elseif conf.method == "CONNECT" then
+ ngx.req.set_method(ngx.HTTP_CONNECT)
+
+ elseif conf.method == "TRACE" then
+ ngx.req.set_method(ngx.HTTP_TRACE)
Review comment:
Recommend to use a table instead of the `if else`
--
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]