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 01:22:26 UTC

[GitHub] [apisix] spacewander commented on a change in pull request #3577: feat: support conditional response rewrite

spacewander commented on a change in pull request #3577:
URL: https://github.com/apache/apisix/pull/3577#discussion_r578860136



##########
File path: apisix/plugins/response-rewrite.lua
##########
@@ -87,13 +112,26 @@ function _M.check_schema(conf)
         end
     end
 
+    if conf.vars then
+        local ok, err = expr.new(conf.vars)
+        if not ok then
+            return nil, "failed to validate the 'vars' expression: " .. err
+        end
+    end
+
     return true
 end
 
 
 do
 
 function _M.body_filter(conf, ctx)
+
+    local ok =  vars_matched(conf, ctx)

Review comment:
       We should cache the result from header_filter.

##########
File path: apisix/plugins/response-rewrite.lua
##########
@@ -107,6 +145,12 @@ function _M.body_filter(conf, ctx)
 end
 
 function _M.header_filter(conf, ctx)
+

Review comment:
       Don't need to extra blank line

##########
File path: apisix/plugins/response-rewrite.lua
##########
@@ -87,13 +112,26 @@ function _M.check_schema(conf)
         end
     end
 
+    if conf.vars then
+        local ok, err = expr.new(conf.vars)
+        if not ok then
+            return nil, "failed to validate the 'vars' expression: " .. err
+        end
+    end
+
     return true
 end
 
 
 do
 
 function _M.body_filter(conf, ctx)
+

Review comment:
       Ditto

##########
File path: apisix/plugins/response-rewrite.lua
##########
@@ -87,13 +112,26 @@ function _M.check_schema(conf)
         end
     end
 
+    if conf.vars then
+        local ok, err = expr.new(conf.vars)
+        if not ok then
+            return nil, "failed to validate the 'vars' expression: " .. err

Review comment:
       Need a test to validate the vars.




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