Conditionally modify upstream response body in Kong #13295
-
I'm currently working with Kong and I need to modify the body of upstream responses based on certain conditions. Specifically, I want to modify the body only if the request is a POST request. I've tried using the "response transformer" plugin, but I can't figure out how to add this specific condition. Here are the points I need clarification on: Did I misconfigure the "response transformer" plugin? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
@stiti-bacem In order to restrict a plugin to specific HTTP methods, you can create a separate route for _format_version: "2.1"
services:
- name: example-service
url: http://web
routes:
- name: post-route
paths:
- /
methods:
- POST
plugins:
- name: response-transformer
config:
add:
json:
- "hello: world"
- name: default-route
paths:
- / |
Beta Was this translation helpful? Give feedback.
It is possible to do this using a plugin that is attached to the route. If you don't want to do that, you'll need a custom plugin.