1. Overview
1.1 Plugin Name#
- ModifyResponse Plugin
1.2 Appropriate Scenario#
- This plugin is used for modifying HTTP response status code, response headers or response body parameters.
1.3 Plugin functionality#
- Reset HTTP response status code
- Add, set, replace or remove HTTP response headers.
- Add, replace or remove HTTP response body(JSON) parameters.
1.4 Plugin Code#
- Core module
shenyu-plugin-modify-response - Core class
org.apache.shenyu.plugin.modify.response.ModifyResponsePlugin
1.5 Added since which shenyu version#
- 2.4.0
2. How to use plugin
2.1 Plugin-use procedure chart#

2.2 Import pom#
- import maven config in shenyu-bootstrap project's
pom.xmlfile.
<dependency> <groupId>org.apache.shenyu</groupId> <artifactId>shenyu-spring-boot-starter-gateway</artifactId> <version>${project.version}</version> </dependency>2.3 Enable plugin#
- In
shenyu-admin--> BasicConfig --> Plugin -->modifyResponseset Status enable. 
2.4 Config plugin#
- Selector and rule config, please refer: Selector and rule config.
- In
shenyu-admin-->PluginList-->HttpProcess-->modifyResponse, add selector config first,then add rule config:- Add selector config

- Add rule config

- Add selector config
2.5 Examples#
Here is an example of client project shenyu-examples-http.
2.5.1 Example reset HTTP response status code#
2.5.1.1 Refer Local Deployment to start admin and bootstrap.#
2.5.1.2 Refer 2.2 to import pom and restart bootstrap.#
2.5.1.3 Refer 2.3 to enable plugin.#
2.5.1.4 Refer 2.4 to add plugin config.#
Add plugin config:

2.5.1.5 Call Interface#

2.5.2 Example modify HTTP response headers#
2.5.2.1 Refer Local Deployment to start admin and bootstrap.#
2.5.2.2 Refer 2.2 to import pom and restart bootstrap.#
2.5.2.3 Refer 2.3 to enable plugin.#
2.5.2.4 Refer 2.4 to add plugin config.#
Add plugin config:

2.5.2.5 Call Interface#

2.5.3 Example modify HTTP response body#
2.5.3.1 Refer Local Deployment to start admin and bootstrap.#
2.5.3.2 Refer 2.2 to import pom and restart bootstrap.#
2.5.3.3 Refer 2.3 to enable plugin.#
2.5.3.4 Refer 2.4 to add plugin config.#
Add plugin config:

2.5.3.5 Call Interface#

3. How to disable plugin#
- In
shenyu-admin--> BasicConfig --> Plugin -->modifyResponseset Status disable.

4. rule parameter list#
for modifying status code:
statusCode: reset response status code
for modifying response headers:
addHeaders: add response headers,k-vformatsetHeaders: set response headers,k-vformatreplaceHeaderKeys: replace response headers,keyis matching to the header key that should be replacing, value is target value after replacingremoveHeaderKeys: remove response headers,keyis matching to the header key that should be removing
for modifying response body:
addBodyKeys: add response body parametersreplaceBodyKeys: replace response body parameters,keyis matching to the body(JSON) key that should be replacing, value is target value after replacingremoveBodyKeys: remove response body parameters,keyis matching to the body(JSON) key that should be removing