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/02/19 03:47:42 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_r578905980



##########
File path: apisix/plugins/proxy-rewrite.lua
##########
@@ -178,6 +183,31 @@ function _M.rewrite(conf, ctx)
         ctx.var.upstream_uri = upstream_uri
     end
 
+    -- enum    = {"GET", "POST","PUT",""PATCH,"DELETE"}
+    -- 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 == "PATCH" then
+        ngx.req.set_method(ngx.HTTP_PATCH)
+
+      elseif conf.method == "DELETE" then
+        ngx.req.set_method(ngx.HTTP_DELETE)
+      else
+        core.log.warn("Invalid HTTP method: ", conf.method)
+      end
+
+      core.log.info("changed HTTP method from ", old_method, " to ", conf.method)

Review comment:
       The variable `old_method` is not defined.




----------------------------------------------------------------
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