You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shenyu.apache.org by de...@apache.org on 2021/07/08 03:42:50 UTC
[incubator-shenyu-website] branch main updated: [#74]add docment
for ModifyResponsePlugin (#74)
This is an automated email from the ASF dual-hosted git repository.
dengliming pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-shenyu-website.git
The following commit(s) were added to refs/heads/main by this push:
new b6a806f [#74]add docment for ModifyResponsePlugin (#74)
b6a806f is described below
commit b6a806f373b4d4086dcc74de7181d86b9f4d4142
Author: Bruce.Du <34...@qq.com>
AuthorDate: Thu Jul 8 11:42:40 2021 +0800
[#74]add docment for ModifyResponsePlugin (#74)
* add docment for ModifyResponsePlugin
* translate the English
* add directory,translate the English
* update modifyResponsePlugin picture
* update en directory
---
content/en/projects/shenyu/_index.md | 92 +++++++++++++--------
.../shenyu/modify-response-plugin/index.md | 64 ++++++++++++++
content/zh/projects/shenyu/_index.md | 3 +-
.../shenyu/modify-response-plugin/index.md | 64 ++++++++++++++
.../plugin/modify-response/modifyBody-cn.png | Bin 0 -> 41454 bytes
.../plugin/modify-response/modifyBody-en.png | Bin 0 -> 41604 bytes
.../plugin/modify-response/modifyHeader-cn.png | Bin 0 -> 53287 bytes
.../plugin/modify-response/modifyHeader-en.png | Bin 0 -> 52335 bytes
.../plugin/modify-response/modifyStatus-cn.png | Bin 0 -> 24206 bytes
.../plugin/modify-response/modifyStatus-en.png | Bin 0 -> 24939 bytes
10 files changed, 186 insertions(+), 37 deletions(-)
diff --git a/content/en/projects/shenyu/_index.md b/content/en/projects/shenyu/_index.md
index f7bcf95..881e886 100644
--- a/content/en/projects/shenyu/_index.md
+++ b/content/en/projects/shenyu/_index.md
@@ -85,42 +85,62 @@ sidebar:
link: 'quick-start-tars'
- title: 'Plugins'
sub:
- - title: 'Divide Plugin'
- link: 'divide-plugin'
- - title: 'Dubbo Plugin'
- link: 'dubbo-plugin'
- - title: 'SpringCloud Plugin'
- link: 'spring-cloud-plugin'
- - title: 'Sofa Plugin'
- link: 'sofa-plugin'
- - title: 'RateLimiter Plugin'
- link: 'rate-limiter-plugin'
- - title: 'Hystrix Plugin'
- link: 'hystrix-plugin'
- - title: 'Sentinel Plugin'
- link: 'sentinel-plugin'
- - title: 'Resilience4j Plugin'
- link: 'resilience4j-plugin'
- - title: 'Monitor Plugin'
- link: 'monitor-plugin'
- - title: 'Waf Plugin'
- link: 'waf-plugin'
- - title: 'Sign Plugin'
- link: 'sign-plugin'
- - title: 'Rewrite Plugin'
- link: 'rewrite-plugin'
- - title: 'Websocket Plugin'
- link: 'websocket-plugin'
- - title: 'Context Path Plugin'
- link: 'context-path-plugin'
- - title: 'Redirect Plugin'
- link: 'redirect-plugin'
- - title: 'Logging Plugin'
- link: 'logging-plugin'
- - title: 'OAuth2 Plugin'
- link: 'oauth2-plugin'
- - title: 'JWT Plugin'
- link: 'jwt-plugin'
+ - title: 'Http Process'
+ sub:
+ - title: 'Divide Plugin'
+ link: 'divide-plugin'
+ - title: 'Rewrite Plugin'
+ link: 'rewrite-plugin'
+ - title: 'Redirect Plugin'
+ link: 'redirect-plugin'
+ - title: 'Request Plugin'
+ link: 'request-plugin'
+ - title: 'Context-path Plugin'
+ link: 'context-path-plugin'
+ - title: 'Param-mapping Plugin'
+ link: 'param-mapping-plugin'
+ - title: 'ModifyResponse Plugin'
+ link: 'modify-response-plugin'
+ - title: 'RPC Proxy'
+ sub:
+ - title: 'Dubbo Plugin'
+ link: 'dubbo-plugin'
+ - title: 'Spring Cloud Plugin'
+ link: 'spring-cloud-plugin'
+ - title: 'Sofa Plugin'
+ link: 'sofa-plugin'
+ - title: 'gRPC Plugin'
+ link: 'grpc-plugin'
+ - title: 'Tars Plugin'
+ link: 'tars-plugin'
+ - title: 'Motan Plugin'
+ link: 'motan-plugin'
+ - title: 'Fuse and current limit'
+ sub:
+ - title: 'Hystrix Plugin'
+ link: 'hystrix-plugin'
+ - title: 'Sentinel Plugin'
+ link: 'sentinel-plugin'
+ - title: 'Resilience4j Plugin'
+ link: 'resilience4j-plugin'
+ - title: 'RateLimiter Plugin'
+ link: 'rate-limiter-plugin'
+ - title: 'Authority Authentication'
+ sub:
+ - title: 'Waf Plugin'
+ link: 'waf-plugin'
+ - title: 'Sign Plugin'
+ link: 'sign-plugin'
+ - title: 'JWT Plugin'
+ link: 'jwt-plugin'
+ - title: 'OAuth 2 Plugin'
+ link: 'oauth2-plugin'
+ - title: 'Observability'
+ sub:
+ - title: 'Monitor Plugin'
+ link: 'monitor-plugin'
+ - title: 'Logging Plugin'
+ link: 'logging-plugin'
- title: 'Developer Guide'
sub:
- title: 'Custom filter'
diff --git a/content/en/projects/shenyu/modify-response-plugin/index.md b/content/en/projects/shenyu/modify-response-plugin/index.md
new file mode 100644
index 0000000..42a4c72
--- /dev/null
+++ b/content/en/projects/shenyu/modify-response-plugin/index.md
@@ -0,0 +1,64 @@
+---
+title: ModifyResponse Plugin
+keywords: modifyResponse
+description: modifyResponse Plugin
+---
+
+## Description
+
+* modifyResponse is a native plugin of ShenYu Gateway and is used to edit response header and body and statusCode.
+
+
+## Plugin Setting
+
+* 在 `shenyu-admin` -> plugin management --> `modifyResponse`set to enable.
+
+## Plugin Use
+
+* Introduce `modifyResponse` dependency in the pom.xml file of the gateway.
+
+```xml
+ <!-- shenyu modify response plugin start-->
+<dependency>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-spring-boot-starter-plugin-modify-response</artifactId>
+ <version>${project.version}</version>
+</dependency>
+ <!-- shenyu modify response plugin end-->
+```
+
+* Selectors and rules, please refer to:[selector](../selector-and-rule)。
+
+ * nly those matched requests can be modify response.
+
+
+## ModifyResponsePlugin Guide
+* 1.Configuration selector
+* 2.Configuration rule
+* 3.modify response statusCode
+ 
+* 4.modify response header
+ 
+* 5.modify response body
+ 
+* param details:
+ * addHeaders: add response header,key-value.
+ * setHeaders: set response header,key-value.
+ * replaceHeaderKeys: replace response header name,key is the value to be replaced,value is the value after replacement
+ * removeHeaderKeys: remove response header key
+ * statusCode: response status code
+ * addBodyKeys: add response body
+ * replaceBodyKeys: replace response body ,key is the value to be replaced,value is the value after replacement
+ * removeBodyKeys: remove response body key
+
+modify response body is achieved through JSONPath,`$.` represents the root directory.
+
+use the configuration,unopened the plugin,response body is
+```json
+"id":3,"name":"hello world findById"}
+```
+open the plugin,response body is
+```json
+"id2":3,"add":"4"}
+```
+
diff --git a/content/zh/projects/shenyu/_index.md b/content/zh/projects/shenyu/_index.md
index ed30e97..40f3735 100644
--- a/content/zh/projects/shenyu/_index.md
+++ b/content/zh/projects/shenyu/_index.md
@@ -97,6 +97,8 @@ sidebar:
link: 'context-path-plugin'
- title: 'Param-mapping插件'
link: 'param-mapping-plugin'
+ - title: 'ModifyResponse插件'
+ link: 'modify-response-plugin'
- title: 'RPC 代理'
sub:
- title: 'Dubbo插件'
@@ -137,7 +139,6 @@ sidebar:
link: 'monitor-plugin'
- title: 'Logging插件'
link: 'logging-plugin'
-
- title: '开发者文档'
sub:
- title: '自定义filter'
diff --git a/content/zh/projects/shenyu/modify-response-plugin/index.md b/content/zh/projects/shenyu/modify-response-plugin/index.md
new file mode 100644
index 0000000..06ca52c
--- /dev/null
+++ b/content/zh/projects/shenyu/modify-response-plugin/index.md
@@ -0,0 +1,64 @@
+---
+title: ModifyResponse插件
+keywords: modifyResponse
+description: modifyResponse插件
+---
+
+## 说明
+
+* modifyResponse插件是 ShenYu 网关自带的,用来对响应进行修改的插件。
+
+
+## 插件设置
+
+* 在 `shenyu-admin` -> 插件管理中 --> `modifyResponse`插件设置为开启。
+
+## 插件使用
+
+* 在网关的 pom.xml 文件中添加 `modifyResponse` 的支持。
+
+```xml
+ <!-- shenyu modify response plugin start-->
+<dependency>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-spring-boot-starter-plugin-modify-response</artifactId>
+ <version>${project.version}</version>
+</dependency>
+ <!-- shenyu modify response plugin end-->
+```
+
+* 选择器和规则,请详细看:[选择器规则](../selector-and-rule)。
+
+ * 只有匹配的请求,才会修改响应。
+
+
+## 修改响应插件使用指南
+* 1.配置选择器
+* 2.配置规则
+* 3.修改响应状态码
+
+* 4.修改响应请求头
+
+* 5.修改响应内容
+
+* 参数详情:
+ * addHeaders: 添加请求头,键值对形式
+ * setHeaders: 添加请求头,键值对形式
+ * replaceHeaderKeys: 替换请求头key的name,key是要被替换的值,value是替换后的值
+ * removeHeaderKeys: 移除的请求头的key
+ * statusCode: 响应状态码
+ * addBodyKeys: 添加响应内容
+ * replaceBodyKeys: 替换响应内容,key是要被替换的值,value是替换后的值
+ * removeBodyKeys: 移除的响应内容的key
+
+修改响应体是通过JSONPath来实现的,`$.` 代表根目录
+
+上面的配置,插件开启前,响应内容为
+```json
+"id":3,"name":"hello world findById"}
+```
+插件开启后,响应内容为
+```json
+"id2":3,"add":"4"}
+```
+
diff --git a/static/img/shenyu/plugin/modify-response/modifyBody-cn.png b/static/img/shenyu/plugin/modify-response/modifyBody-cn.png
new file mode 100644
index 0000000..f1a83a6
Binary files /dev/null and b/static/img/shenyu/plugin/modify-response/modifyBody-cn.png differ
diff --git a/static/img/shenyu/plugin/modify-response/modifyBody-en.png b/static/img/shenyu/plugin/modify-response/modifyBody-en.png
new file mode 100644
index 0000000..8574e40
Binary files /dev/null and b/static/img/shenyu/plugin/modify-response/modifyBody-en.png differ
diff --git a/static/img/shenyu/plugin/modify-response/modifyHeader-cn.png b/static/img/shenyu/plugin/modify-response/modifyHeader-cn.png
new file mode 100644
index 0000000..b048bfa
Binary files /dev/null and b/static/img/shenyu/plugin/modify-response/modifyHeader-cn.png differ
diff --git a/static/img/shenyu/plugin/modify-response/modifyHeader-en.png b/static/img/shenyu/plugin/modify-response/modifyHeader-en.png
new file mode 100644
index 0000000..6685efa
Binary files /dev/null and b/static/img/shenyu/plugin/modify-response/modifyHeader-en.png differ
diff --git a/static/img/shenyu/plugin/modify-response/modifyStatus-cn.png b/static/img/shenyu/plugin/modify-response/modifyStatus-cn.png
new file mode 100644
index 0000000..9b70f78
Binary files /dev/null and b/static/img/shenyu/plugin/modify-response/modifyStatus-cn.png differ
diff --git a/static/img/shenyu/plugin/modify-response/modifyStatus-en.png b/static/img/shenyu/plugin/modify-response/modifyStatus-en.png
new file mode 100644
index 0000000..1894a47
Binary files /dev/null and b/static/img/shenyu/plugin/modify-response/modifyStatus-en.png differ