kwanhur commented on a change in pull request #6750:
URL: https://github.com/apache/apisix/pull/6750#discussion_r840624827



##########
File path: apisix/plugins/response-rewrite.lua
##########
@@ -115,6 +152,23 @@ function _M.check_schema(conf)
         end
     end
 
+    if conf.filters then
+        for _, filter in ipairs(conf.filters) do
+            for field, value in pairs(filter) do
+                if type(field) ~= 'string' then

Review comment:
       Ok, had remove it.

##########
File path: apisix/plugins/response-rewrite.lua
##########
@@ -126,7 +180,24 @@ function _M.body_filter(conf, ctx)
         return
     end
 
-    if conf.body then
+    if conf.filters then
+
+        local body = core.response.hold_body_chunk(ctx)
+        if not body then
+            return
+        end
+
+        for _, filter in ipairs(conf.filters) do
+            if filter.scope == "once" then
+                body = re_sub(body, filter.regex, filter.replace, 
filter.options)
+            else
+                body = re_gsub(body, filter.regex, filter.replace, 
filter.options)
+            end
+        end
+
+        ngx.arg[1] = body
+

Review comment:
       Done.




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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to