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 2022/03/11 03:02:48 UTC

[GitHub] [apisix] spacewander commented on issue #5451: request help: Does response-rewrite plugin support partial or regular substitution

spacewander commented on issue #5451:
URL: https://github.com/apache/apisix/issues/5451#issuecomment-1064724614


   Well, personally I prefer to use an array of filters:
   ```
   "filters": [{
     "expr": ... # if given, run the filter when it's evaluated to true. Can be used to support "content-type" and more.
     "kind": "regex", # a string enum would be better
     "scope": ...,
     "pattern": ...,
     ...
   }]
   ```
   
   > equals to 1 then fallback to completely substitute, otherwise goto regex substitute(both in header_filter and body_filter).
   
   "completely substitute" can be named as sub_filter substitute? As Nginx's sub_fitler supports variable, which isn't a plain substitute.
   
   > local body = ngx.arg[1]
   > ngx.arg[1] = sub(conf.filter_pattern, conf.filter_replace, conf.filter_options)
   
   I am afraid we can't do regex in the stream. This requires the regex engine to have stream mode, for example, see https://github.com/google/re2/issues/127.
   In fact, Nginx's sub_filter will buffer the data before substitution. 
   


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org