You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "1056597498 (via GitHub)" <gi...@apache.org> on 2023/08/02 09:56:45 UTC

[GitHub] [apisix] 1056597498 opened a new issue, #9953: help request: How to configure the response-rewrite plugin to perform different rewriting tasks based on different matching conditions?

1056597498 opened a new issue, #9953:
URL: https://github.com/apache/apisix/issues/9953

   ### Description
   
   How to configure the response-rewrite plugin to perform different rewriting tasks based on different matching conditions?
   Example: I need to achieve the following:
   
   - 	When the content_type is "text/html", rewrite the body as "this is html."
   
   - 	When the content_type is "application/javascript", rewrite the body as "this is js."
   
   The configuration I can think of is:	
   `{
       "response-rewrite":{
           "body":"{\"code\":\"ok\",\"message\":\"this is html\"}",
           "vars":[
               [
                   "sent_http_content_type",
                   "~~",
                   "text/html"
               ]
           ]
       }
   }`
   and
   `{
       "response-rewrite":{
           "body":"{\"code\":\"ok\",\"message\":\"this is js\"}",
           "vars":[
               [
                   "sent_http_content_type",
                   "~~",
                   "application/javascript"
               ]
           ]
       }
   }`
   
   But these are two different configurations for the response-rewrite plugin. How should I configure a single response-rewrite plugin to achieve the above requirements?
   
   ### Environment
   
   - APISIX version (run `3.2`):
   - Operating system (run `x86_64  GNU/Linux`):
   - OpenResty / Nginx version (openresty/1.21.4.1):
   - etcd version, if relevant (run `curl http://127.0.0.1:9090/v1/server_info`):
   - APISIX Dashboard version, if relevant:
   - Plugin runner version, for issues related to plugin runners:
   - LuaRocks version, for installation issues (run `luarocks --version`):
   


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

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


[GitHub] [apisix] shreemaan-abhishek commented on issue #9953: help request: How to configure the response-rewrite plugin to perform different rewriting tasks based on different matching conditions?

Posted by "shreemaan-abhishek (via GitHub)" <gi...@apache.org>.
shreemaan-abhishek commented on issue #9953:
URL: https://github.com/apache/apisix/issues/9953#issuecomment-1663764144

   I think this can be done by writing custom code in `serverless-post-plugin` and using it for `body_filter` phase. Do you have any idea on how to modify the response body in `body_filter` phase? I tried using `core.response.exit()` but that doesn't seem to work in `body_filter` phase.


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


[GitHub] [apisix] shreemaan-abhishek commented on issue #9953: help request: How to configure the response-rewrite plugin to perform different rewriting tasks based on different matching conditions?

Posted by "shreemaan-abhishek (via GitHub)" <gi...@apache.org>.
shreemaan-abhishek commented on issue #9953:
URL: https://github.com/apache/apisix/issues/9953#issuecomment-1664915956

   I think this can be done by writing custom code in `serverless-post-plugin` and using it for `body_filter` phase. @monkeyDluffy6017  Do you have any idea on how to modify the response body in `body_filter` phase? I tried using `core.response.exit()` but that doesn't seem to work in `body_filter` phase.


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


[GitHub] [apisix] Revolyssup commented on issue #9953: help request: How to configure the response-rewrite plugin to perform different rewriting tasks based on different matching conditions?

Posted by "Revolyssup (via GitHub)" <gi...@apache.org>.
Revolyssup commented on issue #9953:
URL: https://github.com/apache/apisix/issues/9953#issuecomment-1735427788

   @1056597498 Two completely different responses cannot be configured over the same response rewrite plugin configuration.
   // @shreemaan-abhishek 


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


[GitHub] [apisix] shreemaan-abhishek commented on issue #9953: help request: How to configure the response-rewrite plugin to perform different rewriting tasks based on different matching conditions?

Posted by "shreemaan-abhishek (via GitHub)" <gi...@apache.org>.
shreemaan-abhishek commented on issue #9953:
URL: https://github.com/apache/apisix/issues/9953#issuecomment-1663253559

   please assign this to me @AlinsRan 
   


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


[GitHub] [apisix] Revolyssup closed issue #9953: help request: How to configure the response-rewrite plugin to perform different rewriting tasks based on different matching conditions?

Posted by "Revolyssup (via GitHub)" <gi...@apache.org>.
Revolyssup closed issue #9953: help request: How to configure the response-rewrite plugin to perform different rewriting tasks based on different matching conditions?
URL: https://github.com/apache/apisix/issues/9953


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