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 2019/12/24 09:15:21 UTC

[GitHub] [incubator-apisix] membphis commented on a change in pull request #979: feature: support regex_uri option in proxy-rewrite plugin

membphis commented on a change in pull request #979: feature: support regex_uri option in proxy-rewrite plugin
URL: https://github.com/apache/incubator-apisix/pull/979#discussion_r361112268
 
 

 ##########
 File path: lua/apisix/plugins/proxy-rewrite.lua
 ##########
 @@ -110,7 +122,21 @@ function _M.rewrite(conf, ctx)
         end
     end
 
-    local upstream_uri = conf.uri or ctx.var.uri
+    local upstream_uri = ctx.var.uri
+    if conf.uri ~= nil then
+        upstream_uri = conf.uri
+    elseif conf.regex_uri ~= nil then
+        local uri, _, err = re_sub(ctx.var.uri, conf.regex_uri[1],
+                                   conf.regex_uri[2], "jo")
+        if uri then
+            upstream_uri = uri
+        else
+            core.log.error("failed to substitute the uri ", ctx.var.uri,
 
 Review comment:
   If something goes wrong here, we should respond directly with code `500`.

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


With regards,
Apache Git Services