-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
15 changed files
with
292 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,91 @@ | ||
--- | ||
title: RequestPlugin | ||
keywords: ["RequestPlugin"] | ||
description: RequestPlugin | ||
title: Request Plugin | ||
keywords: ["request"] | ||
description: request plugin | ||
--- | ||
|
||
## Explanation | ||
# 1. Overview | ||
|
||
* When `ShenYu` gateway makes proxy call to target service, it also allows users to add, modify and remove request headers by using 'request' plugin to request parameters, request headers and cookies. | ||
## 1.1 Plugin Name | ||
|
||
## Plugin Setting | ||
* Request Plugin | ||
|
||
* In `shenyu-admin` --> BasicConfig --> Plugin --> `request` , set to enable. | ||
* Introduce `request` support in the pox.xml file of the gateway. | ||
* If the user don't use, please disable the plugin in the background. | ||
## 1.2 Appropriate Scenario | ||
|
||
* The request plugin is able to make customized changes to the request parameters of `uri`. | ||
|
||
## 1.3 Plugin functionality | ||
|
||
* The `Apache ShenYu` gateway allows users to use the `request` plugin to add, modify, and remove request headers to request parameters, request headers, and `Cookie` when proxying a target service. | ||
|
||
## 1.4 Plugin code | ||
|
||
* Core Module `shenyu-plugin-request` | ||
|
||
* Core Class `org.apache.shenyu.plugin.request.RequestPlugin` | ||
|
||
## 1.5 Added Since Which shenyu version | ||
|
||
* Since ShenYu 2.4.0 | ||
|
||
# 2. How to use plugin | ||
|
||
## 2.1 Plugin-use procedure chart | ||
|
||
<img src="/img/shenyu/plugin/request/request-plugin-procedure-en.png" width="40%" height="30%" /> | ||
|
||
## 2.2 Import pom | ||
|
||
- Import maven config in shenyu-bootstrap project's `pom.xml` file, which is already added by default. | ||
|
||
```xml | ||
<!-- apache shenyu request plugin start--> | ||
<dependency> | ||
<groupId>org.apache.shenyu</groupId> | ||
<artifactId>shenyu-spring-boot-starter-plugin-request</artifactId> | ||
<version>${project.version}</version> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<!-- apache shenyu request plugin end--> | ||
``` | ||
|
||
* Selectors and rules, please refer to: [Selector And Rule Config](../../user-guide/admin-usage/selector-and-rule). | ||
* The custom request parameter modification function is performed only for matching requests. | ||
## 2.3 Enable plugin | ||
|
||
- In `shenyu-admin` --> BasicConfig --> Plugin --> `request` set Status enabled. | ||
|
||
> If there is an option to configure a `ruleHandlePageType` on the page here, you can configure any string, e.g. `custom`, which has no effect on the request, and will be removed in later versions. | ||
<img src="/img/shenyu/plugin/request/request-plugin-enable-en.png" width="70%" height="60%" /> | ||
|
||
|
||
## 2.4 Config plugin | ||
|
||
- selectors and rules, only requests that match are forwarded and redirected, see the [Selector And Rule Config](../../user-guide/admin-usage/selector-and-rule) | ||
- `shenyu-admin` Plugin --> `HttpProcess` --> `Request`. Add the selector first, then add the rule: | ||
- Add the selector: | ||
|
||
<img src="/img/shenyu/plugin/request/request-plugin-selector-en.png" width="70%" height="60%" /> | ||
|
||
- Add the rule | ||
|
||
<img src="/img/shenyu/plugin/request/request-plugin-rule-en.png" width="70%" height="60%" /> | ||
|
||
## 2.5 Examples | ||
|
||
### 2.5.1 Adding request parameters | ||
|
||
- When we configure a custom path in `Rules`, it should be a reachable service path. | ||
- When a request is matched, based on the customized path, the `Apache ShenYu` gateway performs a service hop. | ||
|
||
1. Refer to [Local Deployment](https://shenyu.apache.org/docs/deployment/deployment-local)启动 admin 和网关 | ||
2. Refer to 2.2 importing pom and restarting the gateway. | ||
3. Refer to 2.3 enabling Plugin | ||
4. Start the project [shenyu-examples-http](https://github.com/apache/shenyu/tree/master/shenyu-examples/shenyu-examples-http) | ||
5. Refer to 2.4 and [Selector And Rule Config](../../user-guide/admin-usage/selector-and-rule), configuring plugin rules. | ||
6. Call interface:[http-test-api.http](https://github.com/apache/shenyu/blob/master/shenyu-examples/shenyu-examples-http/src/main/http/http-test-api.http) | ||
- Calling the interface declared by the selector and rule will see the request parameters configured in the request plugin. | ||
|
||
<img src="/img/shenyu/plugin/request/request-plugin-example-zh.png" width="70%" height="60%" /> | ||
|
||
## Situation | ||
# 3. How to disable plugin | ||
|
||
* As the name implies, a request plugin is a custom modification of a `URI` request parameter. | ||
* When a request is matched, the custom modification rule is set to change the parameters accepted by the downstream service. | ||
- In `shenyu-admin` --> BasicConfig --> Plugin --> `request` set Status disable. | ||
- | ||
<img src="/img/shenyu/plugin/request/request-plugin-disable-en.png" width="70%" height="60%" /> |
89 changes: 71 additions & 18 deletions
89
...saurus-plugin-content-docs/current/plugin-center/http-process/request-plugin.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,90 @@ | ||
--- | ||
title: Request插件 | ||
keywords: ["RequestPlugin"] | ||
description: RequestPlugin | ||
description: RequestPlugin | ||
--- | ||
|
||
## 说明 | ||
# 1. 概述 | ||
|
||
* `Apache ShenYu` 网关在对目标服务进行代理调用的时候,允许用户使用 `request` 插件对请求参数、请求头以及 `Cookie` 来添加、修改、移除请求头。 | ||
## 1.1 插件名称 | ||
|
||
## 插件设置 | ||
- Request(请求)插件 | ||
|
||
* 在 `shenyu-admin` --> 基础配置 --> 插件管理 --> `request`,设置为开启。 | ||
## 1.2 适用场景 | ||
|
||
- 请求插件能够对 `uri` 的请求参数进行自定义修改。 | ||
|
||
* 在网关的 `pom.xml` 文件中添加 `request` 的支持。 | ||
## 1.3 插件功能 | ||
|
||
* 如果用户不需要,可以把插件禁用。 | ||
- `Apache ShenYu` 网关在对目标服务进行代理调用的时候,允许用户使用 `request` 插件对请求参数、请求头以及 `Cookie` 来添加、修改、移除请求头。 | ||
|
||
## 1.4 插件代码 | ||
|
||
- 核心模块 ```shenyu-plugin-redirect``` | ||
- 核心类 ```org.apache.shenyu.plugin.request.RequestPlugin``` | ||
|
||
## 1.5 添加自哪个 shenyu 版本 | ||
|
||
- 2.4.0 | ||
|
||
# 2. 如何使用插件 | ||
|
||
## 2.1 插件使用流程图 | ||
|
||
<img src="/img/shenyu/plugin/request/request-plugin-procedure-zh.png" width="40%" height="30%" /> | ||
|
||
## 2.2 导入 pom | ||
|
||
- 在网关的 `pom.xml` 文件中添加插件 maven 配置,默认已经添加。 | ||
|
||
```xml | ||
<!-- apache shenyu request plugin start--> | ||
<dependency> | ||
<groupId>org.apache.shenyu</groupId> | ||
<artifactId>shenyu-spring-boot-starter-plugin-request</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<!-- apache shenyu request plugin end--> | ||
<dependency> | ||
<groupId>org.apache.shenyu</groupId> | ||
<artifactId>shenyu-spring-boot-starter-plugin-request</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<!-- apache shenyu request plugin end--> | ||
``` | ||
|
||
* 选择器和规则设置,请参考:[选择器和规则管理](../../user-guide/admin-usage/selector-and-rule)。 | ||
## 2.3 启用插件 | ||
|
||
- 在 `shenyu-admin` --> 基础配置 --> 插件管理 --> `request` 设置为开启。 | ||
|
||
> 如果此处页面上存在需要配置 `ruleHandlePageType` 的选项,可以配置任一字符串,如:`custom`,对请求没有影响,后面版本会移除掉该选项。 | ||
<img src="/img/shenyu/plugin/request/request-plugin-enable-zh.png" width="70%" height="60%" /> | ||
|
||
## 2.4 配置插件 | ||
|
||
- 选择器和规则,只有匹配的请求,才会进行转发和重定向,请参考:[选择器规则管理](../../user-guide/admin-usage/selector-and-rule)。 | ||
- `shenyu-admin`插件列表 --> `HttpProcess` --> `Request`,先添加选择器,然后添加规则: | ||
- 添加选择器: | ||
|
||
<img src="/img/shenyu/plugin/request/request-plugin-selector-zh.png" width="70%" height="60%" /> | ||
|
||
- 添加规则: | ||
|
||
<img src="/img/shenyu/plugin/request/request-plugin-rule-zh.png" width="70%" height="60%" /> | ||
|
||
## 2.5 示例 | ||
|
||
### 2.5.1 添加请求参数 | ||
|
||
- 我们在 `规则` 配置自定义路径时,应该为一个可达的服务路径。 | ||
- 当匹配到请求后,根据自定义的路径,`Apache ShenYu`网关会进行服务跳转。 | ||
1. 参考[本地部署](https://shenyu.apache.org/zh/docs/deployment/deployment-local)启动 admin 和网关 | ||
2. 参考2.2导入 pom 并重启网关 | ||
3. 参考2.3启用插件 | ||
4. 启动 [shenyu-examples-http](https://github.com/apache/shenyu/tree/master/shenyu-examples/shenyu-examples-http) 项目 | ||
5. 参考2.4及[选择器规则管理](../../user-guide/admin-usage/selector-and-rule)配置插件规则 | ||
6. 接口调用:[http-test-api.http](https://github.com/apache/shenyu/blob/master/shenyu-examples/shenyu-examples-http/src/main/http/http-test-api.http) | ||
- 调用选择器和规则声明的接口,将会看到request插件中配置的请求参数。 | ||
|
||
<img src="/img/shenyu/plugin/request/request-plugin-example-zh.png" width="70%" height="60%" /> | ||
|
||
* 只有匹配的请求,才会进行自定义请求参数修改功能。 | ||
# 3. 如何禁用插件 | ||
|
||
## 场景 | ||
- 在 `shenyu-admin` --> 基础配置 --> 插件管理 --> `Request` 设置为禁用。 | ||
|
||
* 顾名思义,请求插件就是对 `uri` 请求参数进行自定义修改。 | ||
* 当匹配到请求后,设置自定义修改规则,就会改变下游服务接受到的参数。 | ||
<img src="/img/shenyu/plugin/request/request-plugin-disable-zh.png" width="70%" height="60%" /> |
89 changes: 71 additions & 18 deletions
89
...-plugin-content-docs/version-2.5.1/plugin-center/http-process/request-plugin.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,90 @@ | ||
--- | ||
title: Request插件 | ||
keywords: ["RequestPlugin"] | ||
description: RequestPlugin | ||
description: RequestPlugin | ||
--- | ||
|
||
## 说明 | ||
# 1. 概述 | ||
|
||
* `Apache ShenYu` 网关在对目标服务进行代理调用的时候,允许用户使用 `request` 插件对请求参数、请求头以及 `Cookie` 来添加、修改、移除请求头。 | ||
## 1.1 插件名称 | ||
|
||
## 插件设置 | ||
- Request(请求)插件 | ||
|
||
* 在 `shenyu-admin` --> 基础配置 --> 插件管理 --> `request`,设置为开启。 | ||
## 1.2 适用场景 | ||
|
||
- 请求插件能够对 `uri` 的请求参数进行自定义修改。 | ||
|
||
* 在网关的 `pom.xml` 文件中添加 `request` 的支持。 | ||
## 1.3 插件功能 | ||
|
||
* 如果用户不需要,可以把插件禁用。 | ||
- `Apache ShenYu` 网关在对目标服务进行代理调用的时候,允许用户使用 `request` 插件对请求参数、请求头以及 `Cookie` 来添加、修改、移除请求头。 | ||
|
||
## 1.4 插件代码 | ||
|
||
- 核心模块 ```shenyu-plugin-redirect``` | ||
- 核心类 ```org.apache.shenyu.plugin.request.RequestPlugin``` | ||
|
||
## 1.5 添加自哪个 shenyu 版本 | ||
|
||
- 2.4.0 | ||
|
||
# 2. 如何使用插件 | ||
|
||
## 2.1 插件使用流程图 | ||
|
||
<img src="/img/shenyu/plugin/request/request-plugin-procedure-zh.png" width="40%" height="30%" /> | ||
|
||
## 2.2 导入 pom | ||
|
||
- 在网关的 `pom.xml` 文件中添加插件 maven 配置,默认已经添加。 | ||
|
||
```xml | ||
<!-- apache shenyu request plugin start--> | ||
<dependency> | ||
<groupId>org.apache.shenyu</groupId> | ||
<artifactId>shenyu-spring-boot-starter-plugin-request</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<!-- apache shenyu request plugin end--> | ||
<dependency> | ||
<groupId>org.apache.shenyu</groupId> | ||
<artifactId>shenyu-spring-boot-starter-plugin-request</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<!-- apache shenyu request plugin end--> | ||
``` | ||
|
||
* 选择器和规则设置,请参考:[选择器和规则管理](../../user-guide/admin-usage/selector-and-rule)。 | ||
## 2.3 启用插件 | ||
|
||
- 在 `shenyu-admin` --> 基础配置 --> 插件管理 --> `request` 设置为开启。 | ||
|
||
> 如果此处页面上存在需要配置 `ruleHandlePageType` 的选项,可以配置任一字符串,如:`custom`,对请求没有影响,后面版本会移除掉该选项。 | ||
<img src="/img/shenyu/plugin/request/request-plugin-enable-zh.png" width="70%" height="60%" /> | ||
|
||
## 2.4 配置插件 | ||
|
||
- 选择器和规则,只有匹配的请求,才会进行转发和重定向,请参考:[选择器规则管理](../../user-guide/admin-usage/selector-and-rule)。 | ||
- `shenyu-admin`插件列表 --> `HttpProcess` --> `Request`,先添加选择器,然后添加规则: | ||
- 添加选择器: | ||
|
||
<img src="/img/shenyu/plugin/request/request-plugin-selector-zh.png" width="70%" height="60%" /> | ||
|
||
- 添加规则: | ||
|
||
<img src="/img/shenyu/plugin/request/request-plugin-rule-zh.png" width="70%" height="60%" /> | ||
|
||
## 2.5 示例 | ||
|
||
### 2.5.1 添加请求参数 | ||
|
||
- 我们在 `规则` 配置自定义路径时,应该为一个可达的服务路径。 | ||
- 当匹配到请求后,根据自定义的路径,`Apache ShenYu`网关会进行服务跳转。 | ||
1. 参考[本地部署](https://shenyu.apache.org/zh/docs/deployment/deployment-local)启动 admin 和网关 | ||
2. 参考2.2导入 pom 并重启网关 | ||
3. 参考2.3启用插件 | ||
4. 启动 [shenyu-examples-http](https://github.com/apache/shenyu/tree/master/shenyu-examples/shenyu-examples-http) 项目 | ||
5. 参考2.4及[选择器规则管理](../../user-guide/admin-usage/selector-and-rule)配置插件规则 | ||
6. 接口调用:[http-test-api.http](https://github.com/apache/shenyu/blob/master/shenyu-examples/shenyu-examples-http/src/main/http/http-test-api.http) | ||
- 调用选择器和规则声明的接口,将会看到request插件中配置的请求参数。 | ||
|
||
<img src="/img/shenyu/plugin/request/request-plugin-example-zh.png" width="70%" height="60%" /> | ||
|
||
* 只有匹配的请求,才会进行自定义请求参数修改功能。 | ||
# 3. 如何禁用插件 | ||
|
||
## 场景 | ||
- 在 `shenyu-admin` --> 基础配置 --> 插件管理 --> `Request` 设置为禁用。 | ||
|
||
* 顾名思义,请求插件就是对 `uri` 请求参数进行自定义修改。 | ||
* 当匹配到请求后,设置自定义修改规则,就会改变下游服务接受到的参数。 | ||
<img src="/img/shenyu/plugin/request/request-plugin-disable-zh.png" width="70%" height="60%" /> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.