How to configure the response-rewrite plugin to perform different rewriting tasks based on different matching conditions? #9954
Unanswered
1056597498
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
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?
Beta Was this translation helpful? Give feedback.
All reactions