From 9b47aaf8e0ccd182ace3c903d429c0a37cfb41b1 Mon Sep 17 00:00:00 2001 From: AhahaGe Date: Fri, 1 Apr 2022 11:11:36 +0800 Subject: [PATCH] [ISSUE #471] add doc for context path plugin for remaining versions (#525) * apache dubbo example doc for version 2.4.0 and 2.4.1 * [DOC] add shenyu.httpclient config param in doc both en and cn #470 * add context path doc for remaining version --- .../http-process/contextpath-plugin.md | 2 +- .../plugins/context-path-plugin.md | 130 +++++++++++++--- .../http-handle/context-path-plugin.md | 121 ++++++++++++--- .../http-handle/context-path-plugin.md | 121 ++++++++++++--- .../http-process/contextpath-plugin.md | 117 ++++++++++++-- .../plugins/context-path-plugin.md | 144 +++++++++++++++--- .../http-handle/context-path-plugin.md | 136 ++++++++++++++--- .../http-handle/context-path-plugin.md | 136 ++++++++++++++--- .../http-process/contextpath-plugin.md | 130 +++++++++++++--- 9 files changed, 882 insertions(+), 155 deletions(-) diff --git a/docs/plugin-center/http-process/contextpath-plugin.md b/docs/plugin-center/http-process/contextpath-plugin.md index eec1245ff3a..963739611db 100644 --- a/docs/plugin-center/http-process/contextpath-plugin.md +++ b/docs/plugin-center/http-process/contextpath-plugin.md @@ -76,7 +76,7 @@ description: contextPath plugin #### 2.5.1.4 Client project config contextPath. -Client project can directly use [shenyu-examples-http]https://github.com/apache/incubator-shenyu/tree/master/shenyu-examples/shenyu-examples-http), and config contextPath in application.yml. +Client project can directly use [shenyu-examples-http](https://github.com/apache/incubator-shenyu/tree/master/shenyu-examples/shenyu-examples-http), and config contextPath in application.yml. ![](/img/shenyu/plugin/context-path/client-project-config.png) diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-2.3.0/plugins/context-path-plugin.md b/i18n/zh/docusaurus-plugin-content-docs/version-2.3.0/plugins/context-path-plugin.md index 84b94c60054..6b3fbd7253b 100755 --- a/i18n/zh/docusaurus-plugin-content-docs/version-2.3.0/plugins/context-path-plugin.md +++ b/i18n/zh/docusaurus-plugin-content-docs/version-2.3.0/plugins/context-path-plugin.md @@ -1,35 +1,125 @@ --- sidebar_position: 14 title: Context Path插件 -keywords: ["context_path"] -description: context_path插件 +keywords: ["contextPath"] +description: contextPath插件 --- -## 说明 +# 1. 概述 -* soul网关在对目标服务调用的时候,还容许用户使用 `context_path` 插件来重写请求路径的contextPath +## 1.1 插件名称 -## 插件设置 +* 上下文路径插件 -* 在 `soul-admin` --> 插件管理 --> `context_path` 设置为开启。 -* 在网关的 pom.xml 文件中添加 `context_path` 的支持。 -* 如果用户不需要,可以把插件禁用。 +## 1.2 适用场景 + +* 不同的服务可以通过设置不同的上下文路径来做服务的流量治理 + +## 1.3 插件功能 + +* 设置服务的上下文路径 +* 在接口调用的时候插件统一给服务的接口地址加上前缀 + +## 1.4 插件代码 + +* 核心模块 ```shenyu-plugin-context-path``` +* 核心类 ```org.apache.shenyu.plugin.context.path.ContextPathPlugin``` + +## 1.5 添加自哪个 shenyu 版本 + +* 2.3.0 + +# 2. 如何使用插件 + +## 2.1 插件使用流程图 + +![](/img/shenyu/plugin/context-path/procedure-cn.png) + +## 2.2 导入 pom + +- 在网关的 `pom.xml` 文件中添加插件 maven 配置。 ```xml - - org.dromara - soul-spring-boot-starter-plugin-context-path - ${last.version} + org.apache.shenyu + shenyu-spring-boot-starter-gateway + ${project.version} - -``` +``` + +## 2.3 启用插件 + +- 在 `shenyu-admin` --> 基础配置 --> 插件管理 --> `contextPath` 设置为开启。 + +![](/img/shenyu/plugin/context-path/enable-cn.png) + +## 2.4 配置插件 + +- 配置客户端项目的 contextPath + +![](/img/shenyu/plugin/context-path/client-project-config.png) + +- 选择器和规则设置,请参考:[选择器和规则管理](../../user-guide/admin-usage/selector-and-rule)。 +- shenyu-admin contextPath 插件配置,可以配置 contextPath 和 addPrefix:contextPath 定义了 contextPath 的值,addPrefix 定义了接口调用时需要自动增加的的前缀。 + +![](/img/shenyu/plugin/context-path/plugin-config-cn.png) + +## 2.5 示例 + +### 2.5.1 示例 设置服务的上下文路径 + +#### 2.5.1.1 参考[本地部署](https://shenyu.apache.org/zh/docs/deployment/deployment-local)启动 admin 和网关 + +#### 2.5.1.2 参考 2.2 导入 pom 并重启网关 + +#### 2.5.1.3 参考 2.3 启用插件 + +#### 2.5.1.4 客户端项目配置 contextPath + +客户端项目可以直接使用 [shenyu-examples-http](https://github.com/apache/incubator-shenyu/tree/master/shenyu-examples/shenyu-examples-http),并在 application.yml 中配置 contextPath。 + +![](/img/shenyu/plugin/context-path/client-project-config.png) + +配置完成后启动,可以看到 shenyu-admin 中多了一条 context 的 selector 和 rule 配置。 + +![](/img/shenyu/plugin/context-path/context-path-selector-and-rule-cn.png) + +#### 2.5.1.5 接口调用 + +![](/img/shenyu/plugin/context-path/invoke-interface.png) + +### 2.5.2 示例 增加前缀 + +#### 2.5.2.1 参考[本地部署](https://shenyu.apache.org/zh/docs/deployment/deployment-local)启动 admin 和网关 + +#### 2.5.2.2 参考 2.2 导入 pom 并重启网关 + +#### 2.5.2.3 参考 2.3 启用插件 + +#### 2.5.2.4 客户端项目配置 contextPath + +客户端项目可以直接使用 [shenyu-examples-http](https://github.com/apache/incubator-shenyu/tree/master/shenyu-examples/shenyu-examples-http),并在 application.yml 中配置 contextPath。 + +![](/img/shenyu/plugin/context-path/client-project-config.png) + +配置完成后启动,可以看到 shenyu-admin 中多了一条 context 的 selector 和 rule 配置。 + +![](/img/shenyu/plugin/context-path/context-path-selector-and-rule-cn.png) + +#### 2.5.2.5 修改 addPrefix 的值 + +![](/img/shenyu/plugin/context-path/add-prefix-cn.png) + +#### 2.5.2.6 修改选择器和条件配置中 uri 的值,删除掉 addPrefix 部分,由于本例使用了 http 协议的服务,因此需要修改 divide 插件。 + +![](/img/shenyu/plugin/context-path/remove-add-prefix-cn.png) + +#### 2.5.2.5 接口调用 + +![](/img/shenyu/plugin/context-path/invoke-interface-add-prefix.png) -* 选择器和规则,请详细看:[选择器规则](../admin/selector-and-rule)。 -* 只有匹配的请求,并且配置规则才会进行重写contextPath。 +# 3. 如何禁用插件 -## 场景 +- 在 `shenyu-admin` --> 基础配置 --> 插件管理 --> `contextPath` 设置为禁用。 -* 顾名思义,context_path插件就是对uri的`contextPath`重新定义。 -* 当匹配到请求后,设置自定义的`contextPath`,那么就会根据请求的Url截取自定义的`contextPath`获取真正的Url,例如请求路径为`/soul/http/order`, - 配置的contextPath为`/soul/http`,那么真正请求的url为`/order`。 +![](/img/shenyu/plugin/context-path/disable-cn.png) diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-2.4.0/plugin-center/http-handle/context-path-plugin.md b/i18n/zh/docusaurus-plugin-content-docs/version-2.4.0/plugin-center/http-handle/context-path-plugin.md index 88a3bfb0c7c..74a254cf60b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/version-2.4.0/plugin-center/http-handle/context-path-plugin.md +++ b/i18n/zh/docusaurus-plugin-content-docs/version-2.4.0/plugin-center/http-handle/context-path-plugin.md @@ -1,37 +1,124 @@ --- title: Context Path插件 -keywords: ["context_path"] -description: context_path插件 +keywords: ["contextPath"] +description: contextPath插件 --- -## 说明 +# 1. 概述 -* `Apache ShenYu` 网关在对目标服务调用的时候,还容许用户使用 `context_path` 插件来重写请求路径的 `contextPath` +## 1.1 插件名称 -## 插件设置 +* 上下文路径插件 -- 在 `shenyu-admin` --> 基础配置 --> 插件管理 --> `context_path` 设置为开启。 -- 如果用户不需要,可以把插件禁用。 +## 1.2 适用场景 -## 插件使用 +* 不同的服务可以通过设置不同的上下文路径来做服务的流量治理 -- 在网关的 `pom.xml` 文件中添加 `context_path` 的支持。 +## 1.3 插件功能 + +* 设置服务的上下文路径 +* 在接口调用的时候插件统一给服务的接口地址加上前缀 + +## 1.4 插件代码 + +* 核心模块 ```shenyu-plugin-context-path``` +* 核心类 ```org.apache.shenyu.plugin.context.path.ContextPathPlugin``` + +## 1.5 添加自哪个 shenyu 版本 + +* 2.3.0 + +# 2. 如何使用插件 + +## 2.1 插件使用流程图 + +![](/img/shenyu/plugin/context-path/procedure-cn.png) + +## 2.2 导入 pom + +- 在网关的 `pom.xml` 文件中添加插件 maven 配置。 ```xml - org.apache.shenyu - shenyu-spring-boot-starter-plugin-context-path + shenyu-spring-boot-starter-gateway ${project.version} - ``` +## 2.3 启用插件 + +- 在 `shenyu-admin` --> 基础配置 --> 插件管理 --> `contextPath` 设置为开启。 + +![](/img/shenyu/plugin/context-path/enable-cn.png) + +## 2.4 配置插件 + +- 配置客户端项目的 contextPath + +![](/img/shenyu/plugin/context-path/client-project-config.png) + - 选择器和规则设置,请参考:[选择器和规则管理](../../user-guide/admin-usage/selector-and-rule)。 -- 只有匹配的请求,并且配置规则才会进行重写`contextPath`。 +- shenyu-admin contextPath 插件配置,可以配置 contextPath 和 addPrefix:contextPath 定义了 contextPath 的值,addPrefix 定义了接口调用时需要自动增加的的前缀。 + +![](/img/shenyu/plugin/context-path/plugin-config-cn.png) + +## 2.5 示例 + +### 2.5.1 示例 设置服务的上下文路径 + +#### 2.5.1.1 参考[本地部署](https://shenyu.apache.org/zh/docs/deployment/deployment-local)启动 admin 和网关 + +#### 2.5.1.2 参考 2.2 导入 pom 并重启网关 + +#### 2.5.1.3 参考 2.3 启用插件 + +#### 2.5.1.4 客户端项目配置 contextPath + +客户端项目可以直接使用 [shenyu-examples-http](https://github.com/apache/incubator-shenyu/tree/master/shenyu-examples/shenyu-examples-http),并在 application.yml 中配置 contextPath。 + +![](/img/shenyu/plugin/context-path/client-project-config.png) + +配置完成后启动,可以看到 shenyu-admin 中多了一条 context 的 selector 和 rule 配置。 + +![](/img/shenyu/plugin/context-path/context-path-selector-and-rule-cn.png) + +#### 2.5.1.5 接口调用 + +![](/img/shenyu/plugin/context-path/invoke-interface.png) + +### 2.5.2 示例 增加前缀 + +#### 2.5.2.1 参考[本地部署](https://shenyu.apache.org/zh/docs/deployment/deployment-local)启动 admin 和网关 + +#### 2.5.2.2 参考 2.2 导入 pom 并重启网关 + +#### 2.5.2.3 参考 2.3 启用插件 + +#### 2.5.2.4 客户端项目配置 contextPath + +客户端项目可以直接使用 [shenyu-examples-http](https://github.com/apache/incubator-shenyu/tree/master/shenyu-examples/shenyu-examples-http),并在 application.yml 中配置 contextPath。 + +![](/img/shenyu/plugin/context-path/client-project-config.png) + +配置完成后启动,可以看到 shenyu-admin 中多了一条 context 的 selector 和 rule 配置。 + +![](/img/shenyu/plugin/context-path/context-path-selector-and-rule-cn.png) + +#### 2.5.2.5 修改 addPrefix 的值 + +![](/img/shenyu/plugin/context-path/add-prefix-cn.png) + +#### 2.5.2.6 修改选择器和条件配置中 uri 的值,删除掉 addPrefix 部分,由于本例使用了 http 协议的服务,因此需要修改 divide 插件。 + +![](/img/shenyu/plugin/context-path/remove-add-prefix-cn.png) + +#### 2.5.2.5 接口调用 + +![](/img/shenyu/plugin/context-path/invoke-interface-add-prefix.png) + +# 3. 如何禁用插件 -## 场景 +- 在 `shenyu-admin` --> 基础配置 --> 插件管理 --> `contextPath` 设置为禁用。 -* 顾名思义,`context_path`插件就是对uri的`contextPath`重新定义。 -* 当匹配到请求后,设置自定义的`contextPath`,那么就会根据请求的Url截取自定义的`contextPath`获取真正的 `url` ,例如请求路径为`/shenyu/http/order`, - 配置的contextPath为`/shenyu/http`,那么真正请求的url为`/order`。 +![](/img/shenyu/plugin/context-path/disable-cn.png) diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-2.4.1/plugin-center/http-handle/context-path-plugin.md b/i18n/zh/docusaurus-plugin-content-docs/version-2.4.1/plugin-center/http-handle/context-path-plugin.md index 88a3bfb0c7c..74a254cf60b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/version-2.4.1/plugin-center/http-handle/context-path-plugin.md +++ b/i18n/zh/docusaurus-plugin-content-docs/version-2.4.1/plugin-center/http-handle/context-path-plugin.md @@ -1,37 +1,124 @@ --- title: Context Path插件 -keywords: ["context_path"] -description: context_path插件 +keywords: ["contextPath"] +description: contextPath插件 --- -## 说明 +# 1. 概述 -* `Apache ShenYu` 网关在对目标服务调用的时候,还容许用户使用 `context_path` 插件来重写请求路径的 `contextPath` +## 1.1 插件名称 -## 插件设置 +* 上下文路径插件 -- 在 `shenyu-admin` --> 基础配置 --> 插件管理 --> `context_path` 设置为开启。 -- 如果用户不需要,可以把插件禁用。 +## 1.2 适用场景 -## 插件使用 +* 不同的服务可以通过设置不同的上下文路径来做服务的流量治理 -- 在网关的 `pom.xml` 文件中添加 `context_path` 的支持。 +## 1.3 插件功能 + +* 设置服务的上下文路径 +* 在接口调用的时候插件统一给服务的接口地址加上前缀 + +## 1.4 插件代码 + +* 核心模块 ```shenyu-plugin-context-path``` +* 核心类 ```org.apache.shenyu.plugin.context.path.ContextPathPlugin``` + +## 1.5 添加自哪个 shenyu 版本 + +* 2.3.0 + +# 2. 如何使用插件 + +## 2.1 插件使用流程图 + +![](/img/shenyu/plugin/context-path/procedure-cn.png) + +## 2.2 导入 pom + +- 在网关的 `pom.xml` 文件中添加插件 maven 配置。 ```xml - org.apache.shenyu - shenyu-spring-boot-starter-plugin-context-path + shenyu-spring-boot-starter-gateway ${project.version} - ``` +## 2.3 启用插件 + +- 在 `shenyu-admin` --> 基础配置 --> 插件管理 --> `contextPath` 设置为开启。 + +![](/img/shenyu/plugin/context-path/enable-cn.png) + +## 2.4 配置插件 + +- 配置客户端项目的 contextPath + +![](/img/shenyu/plugin/context-path/client-project-config.png) + - 选择器和规则设置,请参考:[选择器和规则管理](../../user-guide/admin-usage/selector-and-rule)。 -- 只有匹配的请求,并且配置规则才会进行重写`contextPath`。 +- shenyu-admin contextPath 插件配置,可以配置 contextPath 和 addPrefix:contextPath 定义了 contextPath 的值,addPrefix 定义了接口调用时需要自动增加的的前缀。 + +![](/img/shenyu/plugin/context-path/plugin-config-cn.png) + +## 2.5 示例 + +### 2.5.1 示例 设置服务的上下文路径 + +#### 2.5.1.1 参考[本地部署](https://shenyu.apache.org/zh/docs/deployment/deployment-local)启动 admin 和网关 + +#### 2.5.1.2 参考 2.2 导入 pom 并重启网关 + +#### 2.5.1.3 参考 2.3 启用插件 + +#### 2.5.1.4 客户端项目配置 contextPath + +客户端项目可以直接使用 [shenyu-examples-http](https://github.com/apache/incubator-shenyu/tree/master/shenyu-examples/shenyu-examples-http),并在 application.yml 中配置 contextPath。 + +![](/img/shenyu/plugin/context-path/client-project-config.png) + +配置完成后启动,可以看到 shenyu-admin 中多了一条 context 的 selector 和 rule 配置。 + +![](/img/shenyu/plugin/context-path/context-path-selector-and-rule-cn.png) + +#### 2.5.1.5 接口调用 + +![](/img/shenyu/plugin/context-path/invoke-interface.png) + +### 2.5.2 示例 增加前缀 + +#### 2.5.2.1 参考[本地部署](https://shenyu.apache.org/zh/docs/deployment/deployment-local)启动 admin 和网关 + +#### 2.5.2.2 参考 2.2 导入 pom 并重启网关 + +#### 2.5.2.3 参考 2.3 启用插件 + +#### 2.5.2.4 客户端项目配置 contextPath + +客户端项目可以直接使用 [shenyu-examples-http](https://github.com/apache/incubator-shenyu/tree/master/shenyu-examples/shenyu-examples-http),并在 application.yml 中配置 contextPath。 + +![](/img/shenyu/plugin/context-path/client-project-config.png) + +配置完成后启动,可以看到 shenyu-admin 中多了一条 context 的 selector 和 rule 配置。 + +![](/img/shenyu/plugin/context-path/context-path-selector-and-rule-cn.png) + +#### 2.5.2.5 修改 addPrefix 的值 + +![](/img/shenyu/plugin/context-path/add-prefix-cn.png) + +#### 2.5.2.6 修改选择器和条件配置中 uri 的值,删除掉 addPrefix 部分,由于本例使用了 http 协议的服务,因此需要修改 divide 插件。 + +![](/img/shenyu/plugin/context-path/remove-add-prefix-cn.png) + +#### 2.5.2.5 接口调用 + +![](/img/shenyu/plugin/context-path/invoke-interface-add-prefix.png) + +# 3. 如何禁用插件 -## 场景 +- 在 `shenyu-admin` --> 基础配置 --> 插件管理 --> `contextPath` 设置为禁用。 -* 顾名思义,`context_path`插件就是对uri的`contextPath`重新定义。 -* 当匹配到请求后,设置自定义的`contextPath`,那么就会根据请求的Url截取自定义的`contextPath`获取真正的 `url` ,例如请求路径为`/shenyu/http/order`, - 配置的contextPath为`/shenyu/http`,那么真正请求的url为`/order`。 +![](/img/shenyu/plugin/context-path/disable-cn.png) diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-2.4.2/plugin-center/http-process/contextpath-plugin.md b/i18n/zh/docusaurus-plugin-content-docs/version-2.4.2/plugin-center/http-process/contextpath-plugin.md index 48c9b020bf0..74a254cf60b 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/version-2.4.2/plugin-center/http-process/contextpath-plugin.md +++ b/i18n/zh/docusaurus-plugin-content-docs/version-2.4.2/plugin-center/http-process/contextpath-plugin.md @@ -4,34 +4,121 @@ keywords: ["contextPath"] description: contextPath插件 --- -## 说明 +# 1. 概述 -* `Apache ShenYu` 网关在对目标服务调用的时候,还容许用户使用 `contextPath` 插件来重写请求路径的 `contextPath` +## 1.1 插件名称 -## 插件设置 +* 上下文路径插件 -- 在 `shenyu-admin` --> 基础配置 --> 插件管理 --> `contextPath` 设置为开启。 -- 如果用户不需要,可以把插件禁用。 +## 1.2 适用场景 + +* 不同的服务可以通过设置不同的上下文路径来做服务的流量治理 + +## 1.3 插件功能 + +* 设置服务的上下文路径 +* 在接口调用的时候插件统一给服务的接口地址加上前缀 + +## 1.4 插件代码 + +* 核心模块 ```shenyu-plugin-context-path``` +* 核心类 ```org.apache.shenyu.plugin.context.path.ContextPathPlugin``` -## 插件使用 +## 1.5 添加自哪个 shenyu 版本 -- 在网关的 `pom.xml` 文件中添加 `contextPath` 的支持。 +* 2.3.0 + +# 2. 如何使用插件 + +## 2.1 插件使用流程图 + +![](/img/shenyu/plugin/context-path/procedure-cn.png) + +## 2.2 导入 pom + +- 在网关的 `pom.xml` 文件中添加插件 maven 配置。 ```xml - org.apache.shenyu - shenyu-spring-boot-starter-plugin-context-path + shenyu-spring-boot-starter-gateway ${project.version} - ``` +## 2.3 启用插件 + +- 在 `shenyu-admin` --> 基础配置 --> 插件管理 --> `contextPath` 设置为开启。 + +![](/img/shenyu/plugin/context-path/enable-cn.png) + +## 2.4 配置插件 + +- 配置客户端项目的 contextPath + +![](/img/shenyu/plugin/context-path/client-project-config.png) + - 选择器和规则设置,请参考:[选择器和规则管理](../../user-guide/admin-usage/selector-and-rule)。 -- 只有匹配的请求,并且配置规则才会进行重写`contextPath`。 +- shenyu-admin contextPath 插件配置,可以配置 contextPath 和 addPrefix:contextPath 定义了 contextPath 的值,addPrefix 定义了接口调用时需要自动增加的的前缀。 + +![](/img/shenyu/plugin/context-path/plugin-config-cn.png) + +## 2.5 示例 + +### 2.5.1 示例 设置服务的上下文路径 + +#### 2.5.1.1 参考[本地部署](https://shenyu.apache.org/zh/docs/deployment/deployment-local)启动 admin 和网关 + +#### 2.5.1.2 参考 2.2 导入 pom 并重启网关 + +#### 2.5.1.3 参考 2.3 启用插件 + +#### 2.5.1.4 客户端项目配置 contextPath + +客户端项目可以直接使用 [shenyu-examples-http](https://github.com/apache/incubator-shenyu/tree/master/shenyu-examples/shenyu-examples-http),并在 application.yml 中配置 contextPath。 + +![](/img/shenyu/plugin/context-path/client-project-config.png) + +配置完成后启动,可以看到 shenyu-admin 中多了一条 context 的 selector 和 rule 配置。 + +![](/img/shenyu/plugin/context-path/context-path-selector-and-rule-cn.png) + +#### 2.5.1.5 接口调用 + +![](/img/shenyu/plugin/context-path/invoke-interface.png) + +### 2.5.2 示例 增加前缀 + +#### 2.5.2.1 参考[本地部署](https://shenyu.apache.org/zh/docs/deployment/deployment-local)启动 admin 和网关 + +#### 2.5.2.2 参考 2.2 导入 pom 并重启网关 + +#### 2.5.2.3 参考 2.3 启用插件 + +#### 2.5.2.4 客户端项目配置 contextPath + +客户端项目可以直接使用 [shenyu-examples-http](https://github.com/apache/incubator-shenyu/tree/master/shenyu-examples/shenyu-examples-http),并在 application.yml 中配置 contextPath。 + +![](/img/shenyu/plugin/context-path/client-project-config.png) + +配置完成后启动,可以看到 shenyu-admin 中多了一条 context 的 selector 和 rule 配置。 + +![](/img/shenyu/plugin/context-path/context-path-selector-and-rule-cn.png) + +#### 2.5.2.5 修改 addPrefix 的值 + +![](/img/shenyu/plugin/context-path/add-prefix-cn.png) + +#### 2.5.2.6 修改选择器和条件配置中 uri 的值,删除掉 addPrefix 部分,由于本例使用了 http 协议的服务,因此需要修改 divide 插件。 + +![](/img/shenyu/plugin/context-path/remove-add-prefix-cn.png) + +#### 2.5.2.5 接口调用 + +![](/img/shenyu/plugin/context-path/invoke-interface-add-prefix.png) + +# 3. 如何禁用插件 -## 场景 +- 在 `shenyu-admin` --> 基础配置 --> 插件管理 --> `contextPath` 设置为禁用。 -* 顾名思义,`context_path`插件就是对uri的`contextPath`重新定义。 -* 当匹配到请求后,设置自定义的`contextPath`,那么就会根据请求的Url截取自定义的`contextPath`获取真正的 `url` ,例如请求路径为`/shenyu/http/order`, - 配置的contextPath为`/shenyu/http`,那么真正请求的url为`/order`。 +![](/img/shenyu/plugin/context-path/disable-cn.png) diff --git a/versioned_docs/version-2.3.0/plugins/context-path-plugin.md b/versioned_docs/version-2.3.0/plugins/context-path-plugin.md index 56abb5f1014..817cc24de4a 100755 --- a/versioned_docs/version-2.3.0/plugins/context-path-plugin.md +++ b/versioned_docs/version-2.3.0/plugins/context-path-plugin.md @@ -1,34 +1,128 @@ --- sidebar_position: 14 -title: ContextPath Plugin -keywords: ["context_path"] -description: context_path plugin +title: ContextPath Plugin +keywords: ["contextPath"] +description: contextPath plugin --- -## Explanation +# 1. Overview -* When making invokes to the target service, soul Gateway also allows users to customize the context using the `context_path` plugin. +## 1.1 Plugin Name -## Plugin Setting +* ContextPath Plugin -* In `soul-admin` --> plugin management --> `context_path`, set to enable. -* Introduce `context_path` 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 + +* Different services can do traffic governance of services by setting different context paths. + +## 1.3 Plugin functionality + +* Set the context path for service. +* When the interface is called, the plug-in uniformly prefixes the interface address of the service. + +## 1.4 Plugin Code + +* Core module ```shenyu-plugin-context-path``` +* Core class ```org.apache.shenyu.plugin.context.path.ContextPathPlugin``` + +## 1.5 Added since which shenyu version + +* 2.3.0 + +# 2. How to use plugin + +## 2.1 Plugin-use procedure chart + +![](/img/shenyu/plugin/context-path/procedure-en.png) + +## 2.2 Import pom + +- import maven config in shenyu-bootstrap project's `pom.xml` file. ```xml - - - org.dromara - soul-spring-boot-starter-plugin-context-path - ${last.version} - - -``` - -* Selectors and rules, please refer to: [selector](../admin/selector-and-rule)。 - -## Situation - -* As the name suggests,the context_path plugin redefines the contextPath of URI. -* When the request is matched, the custom `contextPath` is set, then the custom `contextPath` will be intercepted according to the requested Url to obtain the real Url, for example, the request path is `/soul/http/order`, - The configured contextPath is `/soul/http`, then the requested url is `/order`. + + org.apache.shenyu + shenyu-spring-boot-starter-gateway + ${project.version} + +``` + +## 2.3 Enable plugin + +- In `shenyu-admin` --> BasicConfig --> Plugin --> `contextPath` set Status enable. + +![](/img/shenyu/plugin/context-path/enable-en.png) + +## 2.4 Config plugin + +- Set client project's contextPath. + +![](/img/shenyu/plugin/context-path/client-project-config.png) + +- Selector and rule config, please refer: [Selector and rule config](../../user-guide/admin-usage/selector-and-rule). +- shenyu-admin contextPath plugin config, config contextPath and addPrefix, contextPath defines the value of contextPath, +- and addPrefix defines the prefix that needs to be automatically added when the interface is called. + +![](/img/shenyu/plugin/context-path/plugin-config-en.png) + +## 2.5 Examples + +### 2.5.1 Example set service context path + +#### 2.5.1.1 Refer [Local Deployment](https://shenyu.apache.org/docs/deployment/deployment-local/) 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 Client project config contextPath. + +Client project can directly use [shenyu-examples-http](https://github.com/apache/incubator-shenyu/tree/master/shenyu-examples/shenyu-examples-http), and config contextPath in application.yml. + +![](/img/shenyu/plugin/context-path/client-project-config.png) + +- After the configuration is completed, and start client project, you can see that there is an additional context selector and rule configuration in shenyu-admin. + +![](/img/shenyu/plugin/context-path/context-path-selector-and-rule-en.png) + +#### 2.5.1.5 Call Interface + +![](/img/shenyu/plugin/context-path/invoke-interface.png) + +### 2.5.2 Example add prefix + +#### 2.5.2.1 Refer [Local Deployment](https://shenyu.apache.org/docs/deployment/deployment-local/) 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 Client project config contextPath. + +For client project we can directly use [shenyu-examples-http](https://github.com/apache/incubator-shenyu/tree/master/shenyu-examples/shenyu-examples-http), and config contextPath in application.yml. + +![](/img/shenyu/plugin/context-path/client-project-config.png) + +- After the configuration is completed, start client project, you can see that there is an additional context selector and rule configuration in shenyu-admin. + +![](/img/shenyu/plugin/context-path/context-path-selector-and-rule-en.png) + +#### 2.5.2.5 Config addPrefix + +![](/img/shenyu/plugin/context-path/add-prefix-en.png) + +#### 2.5.2.6 Modify the value of uri in the selector and condition configuration to delete the addPrefix part. + +Since this example uses the service of the http protocol, we need to modify the divide plugin. + +![](/img/shenyu/plugin/context-path/remove-add-prefix-en.png) + +#### 2.5.2.5 Call Interface + +![](/img/shenyu/plugin/context-path/invoke-interface-add-prefix.png) + +# 3. How to disable plugin + +- In `shenyu-admin` --> BasicConfig --> Plugin --> `contextPath` set Status disable. + +![](/img/shenyu/plugin/context-path/disable-en.png) diff --git a/versioned_docs/version-2.4.0/plugin-center/http-handle/context-path-plugin.md b/versioned_docs/version-2.4.0/plugin-center/http-handle/context-path-plugin.md index 5f995b7c156..ea740f5a1b3 100644 --- a/versioned_docs/version-2.4.0/plugin-center/http-handle/context-path-plugin.md +++ b/versioned_docs/version-2.4.0/plugin-center/http-handle/context-path-plugin.md @@ -1,33 +1,127 @@ --- -title: Context-Path Plugin -keywords: ["context_path"] -description: context_path plugin +title: ContextPath Plugin +keywords: ["contextPath"] +description: contextPath plugin --- -## Explanation +# 1. Overview -* When making invokes to the target service, `Apache ShenYu` Gateway also allows users to customize the `contextPath` using the `context_path` plugin. +## 1.1 Plugin Name -## Plugin Setting +* ContextPath Plugin -* In `shenyu-admin` --> BasicConfig --> Plugin --> `context_path` , set to enable. -* Introduce `context_path` support in the `pom.xml` file of the gateway. -* If the user don't use, please disable the plugin in the background. +## 1.2 Appropriate Scenario + +* Different services can do traffic governance of services by setting different context paths. + +## 1.3 Plugin functionality + +* Set the context path for service. +* When the interface is called, the plug-in uniformly prefixes the interface address of the service. + +## 1.4 Plugin Code + +* Core module ```shenyu-plugin-context-path``` +* Core class ```org.apache.shenyu.plugin.context.path.ContextPathPlugin``` + +## 1.5 Added since which shenyu version + +* 2.3.0 + +# 2. How to use plugin + +## 2.1 Plugin-use procedure chart + +![](/img/shenyu/plugin/context-path/procedure-en.png) + +## 2.2 Import pom + +- import maven config in shenyu-bootstrap project's `pom.xml` file. ```xml - - - org.apache.shenyu - shenyu-spring-boot-starter-plugin-context-path - ${project.version} - - + + org.apache.shenyu + shenyu-spring-boot-starter-gateway + ${project.version} + ``` -* Selectors and rules, please refer to: [Selector And Rule Config](../../user-guide/admin-usage/selector-and-rule) . +## 2.3 Enable plugin + +- In `shenyu-admin` --> BasicConfig --> Plugin --> `contextPath` set Status enable. + +![](/img/shenyu/plugin/context-path/enable-en.png) + +## 2.4 Config plugin + +- Set client project's contextPath. + +![](/img/shenyu/plugin/context-path/client-project-config.png) + +- Selector and rule config, please refer: [Selector and rule config](../../user-guide/admin-usage/selector-and-rule). +- shenyu-admin contextPath plugin config, config contextPath and addPrefix, contextPath defines the value of contextPath, +- and addPrefix defines the prefix that needs to be automatically added when the interface is called. + +![](/img/shenyu/plugin/context-path/plugin-config-en.png) + +## 2.5 Examples + +### 2.5.1 Example set service context path + +#### 2.5.1.1 Refer [Local Deployment](https://shenyu.apache.org/docs/deployment/deployment-local/) 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 Client project config contextPath. + +Client project can directly use [shenyu-examples-http](https://github.com/apache/incubator-shenyu/tree/master/shenyu-examples/shenyu-examples-http), and config contextPath in application.yml. + +![](/img/shenyu/plugin/context-path/client-project-config.png) + +- After the configuration is completed, and start client project, you can see that there is an additional context selector and rule configuration in shenyu-admin. + +![](/img/shenyu/plugin/context-path/context-path-selector-and-rule-en.png) + +#### 2.5.1.5 Call Interface + +![](/img/shenyu/plugin/context-path/invoke-interface.png) + +### 2.5.2 Example add prefix + +#### 2.5.2.1 Refer [Local Deployment](https://shenyu.apache.org/docs/deployment/deployment-local/) 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 Client project config contextPath. + +For client project we can directly use [shenyu-examples-http](https://github.com/apache/incubator-shenyu/tree/master/shenyu-examples/shenyu-examples-http), and config contextPath in application.yml. + +![](/img/shenyu/plugin/context-path/client-project-config.png) + +- After the configuration is completed, start client project, you can see that there is an additional context selector and rule configuration in shenyu-admin. + +![](/img/shenyu/plugin/context-path/context-path-selector-and-rule-en.png) + +#### 2.5.2.5 Config addPrefix + +![](/img/shenyu/plugin/context-path/add-prefix-en.png) + +#### 2.5.2.6 Modify the value of uri in the selector and condition configuration to delete the addPrefix part. + +Since this example uses the service of the http protocol, we need to modify the divide plugin. + +![](/img/shenyu/plugin/context-path/remove-add-prefix-en.png) + +#### 2.5.2.5 Call Interface + +![](/img/shenyu/plugin/context-path/invoke-interface-add-prefix.png) + +# 3. How to disable plugin -## Situation +- In `shenyu-admin` --> BasicConfig --> Plugin --> `contextPath` set Status disable. -* As the name suggests,the context_path plugin redefines the contextPath of URI. -* When the request is matched, the custom `contextPath` is set, then the custom `contextPath` will be intercepted according to the requested Url to obtain the real Url, for example, the request path is `/shenyu/http/order`, - The configured contextPath is `/shenyu/http`, then the requested `url` is `/order`. +![](/img/shenyu/plugin/context-path/disable-en.png) diff --git a/versioned_docs/version-2.4.1/plugin-center/http-handle/context-path-plugin.md b/versioned_docs/version-2.4.1/plugin-center/http-handle/context-path-plugin.md index 5f995b7c156..ea740f5a1b3 100644 --- a/versioned_docs/version-2.4.1/plugin-center/http-handle/context-path-plugin.md +++ b/versioned_docs/version-2.4.1/plugin-center/http-handle/context-path-plugin.md @@ -1,33 +1,127 @@ --- -title: Context-Path Plugin -keywords: ["context_path"] -description: context_path plugin +title: ContextPath Plugin +keywords: ["contextPath"] +description: contextPath plugin --- -## Explanation +# 1. Overview -* When making invokes to the target service, `Apache ShenYu` Gateway also allows users to customize the `contextPath` using the `context_path` plugin. +## 1.1 Plugin Name -## Plugin Setting +* ContextPath Plugin -* In `shenyu-admin` --> BasicConfig --> Plugin --> `context_path` , set to enable. -* Introduce `context_path` support in the `pom.xml` file of the gateway. -* If the user don't use, please disable the plugin in the background. +## 1.2 Appropriate Scenario + +* Different services can do traffic governance of services by setting different context paths. + +## 1.3 Plugin functionality + +* Set the context path for service. +* When the interface is called, the plug-in uniformly prefixes the interface address of the service. + +## 1.4 Plugin Code + +* Core module ```shenyu-plugin-context-path``` +* Core class ```org.apache.shenyu.plugin.context.path.ContextPathPlugin``` + +## 1.5 Added since which shenyu version + +* 2.3.0 + +# 2. How to use plugin + +## 2.1 Plugin-use procedure chart + +![](/img/shenyu/plugin/context-path/procedure-en.png) + +## 2.2 Import pom + +- import maven config in shenyu-bootstrap project's `pom.xml` file. ```xml - - - org.apache.shenyu - shenyu-spring-boot-starter-plugin-context-path - ${project.version} - - + + org.apache.shenyu + shenyu-spring-boot-starter-gateway + ${project.version} + ``` -* Selectors and rules, please refer to: [Selector And Rule Config](../../user-guide/admin-usage/selector-and-rule) . +## 2.3 Enable plugin + +- In `shenyu-admin` --> BasicConfig --> Plugin --> `contextPath` set Status enable. + +![](/img/shenyu/plugin/context-path/enable-en.png) + +## 2.4 Config plugin + +- Set client project's contextPath. + +![](/img/shenyu/plugin/context-path/client-project-config.png) + +- Selector and rule config, please refer: [Selector and rule config](../../user-guide/admin-usage/selector-and-rule). +- shenyu-admin contextPath plugin config, config contextPath and addPrefix, contextPath defines the value of contextPath, +- and addPrefix defines the prefix that needs to be automatically added when the interface is called. + +![](/img/shenyu/plugin/context-path/plugin-config-en.png) + +## 2.5 Examples + +### 2.5.1 Example set service context path + +#### 2.5.1.1 Refer [Local Deployment](https://shenyu.apache.org/docs/deployment/deployment-local/) 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 Client project config contextPath. + +Client project can directly use [shenyu-examples-http](https://github.com/apache/incubator-shenyu/tree/master/shenyu-examples/shenyu-examples-http), and config contextPath in application.yml. + +![](/img/shenyu/plugin/context-path/client-project-config.png) + +- After the configuration is completed, and start client project, you can see that there is an additional context selector and rule configuration in shenyu-admin. + +![](/img/shenyu/plugin/context-path/context-path-selector-and-rule-en.png) + +#### 2.5.1.5 Call Interface + +![](/img/shenyu/plugin/context-path/invoke-interface.png) + +### 2.5.2 Example add prefix + +#### 2.5.2.1 Refer [Local Deployment](https://shenyu.apache.org/docs/deployment/deployment-local/) 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 Client project config contextPath. + +For client project we can directly use [shenyu-examples-http](https://github.com/apache/incubator-shenyu/tree/master/shenyu-examples/shenyu-examples-http), and config contextPath in application.yml. + +![](/img/shenyu/plugin/context-path/client-project-config.png) + +- After the configuration is completed, start client project, you can see that there is an additional context selector and rule configuration in shenyu-admin. + +![](/img/shenyu/plugin/context-path/context-path-selector-and-rule-en.png) + +#### 2.5.2.5 Config addPrefix + +![](/img/shenyu/plugin/context-path/add-prefix-en.png) + +#### 2.5.2.6 Modify the value of uri in the selector and condition configuration to delete the addPrefix part. + +Since this example uses the service of the http protocol, we need to modify the divide plugin. + +![](/img/shenyu/plugin/context-path/remove-add-prefix-en.png) + +#### 2.5.2.5 Call Interface + +![](/img/shenyu/plugin/context-path/invoke-interface-add-prefix.png) + +# 3. How to disable plugin -## Situation +- In `shenyu-admin` --> BasicConfig --> Plugin --> `contextPath` set Status disable. -* As the name suggests,the context_path plugin redefines the contextPath of URI. -* When the request is matched, the custom `contextPath` is set, then the custom `contextPath` will be intercepted according to the requested Url to obtain the real Url, for example, the request path is `/shenyu/http/order`, - The configured contextPath is `/shenyu/http`, then the requested `url` is `/order`. +![](/img/shenyu/plugin/context-path/disable-en.png) diff --git a/versioned_docs/version-2.4.2/plugin-center/http-process/contextpath-plugin.md b/versioned_docs/version-2.4.2/plugin-center/http-process/contextpath-plugin.md index 281f3ab0248..ea740f5a1b3 100644 --- a/versioned_docs/version-2.4.2/plugin-center/http-process/contextpath-plugin.md +++ b/versioned_docs/version-2.4.2/plugin-center/http-process/contextpath-plugin.md @@ -4,30 +4,124 @@ keywords: ["contextPath"] description: contextPath plugin --- -## Explanation +# 1. Overview -* When making invokes to the target service, `Apache ShenYu` Gateway also allows users to customize the `contextPath` using the `contextPath` plugin. +## 1.1 Plugin Name -## Plugin Setting +* ContextPath Plugin -* In `shenyu-admin` --> BasicConfig --> Plugin --> `contextPath` , set to enable. -* Introduce `contextPath` support in the `pom.xml` file of the gateway. -* If the user don't use, please disable the plugin in the background. +## 1.2 Appropriate Scenario + +* Different services can do traffic governance of services by setting different context paths. + +## 1.3 Plugin functionality + +* Set the context path for service. +* When the interface is called, the plug-in uniformly prefixes the interface address of the service. + +## 1.4 Plugin Code + +* Core module ```shenyu-plugin-context-path``` +* Core class ```org.apache.shenyu.plugin.context.path.ContextPathPlugin``` + +## 1.5 Added since which shenyu version + +* 2.3.0 + +# 2. How to use plugin + +## 2.1 Plugin-use procedure chart + +![](/img/shenyu/plugin/context-path/procedure-en.png) + +## 2.2 Import pom + +- import maven config in shenyu-bootstrap project's `pom.xml` file. ```xml - - - org.apache.shenyu - shenyu-spring-boot-starter-plugin-context-path - ${project.version} - - + + org.apache.shenyu + shenyu-spring-boot-starter-gateway + ${project.version} + ``` -* Selectors and rules, please refer to: [Selector And Rule Config](../../user-guide/admin-usage/selector-and-rule) . +## 2.3 Enable plugin + +- In `shenyu-admin` --> BasicConfig --> Plugin --> `contextPath` set Status enable. + +![](/img/shenyu/plugin/context-path/enable-en.png) + +## 2.4 Config plugin + +- Set client project's contextPath. + +![](/img/shenyu/plugin/context-path/client-project-config.png) + +- Selector and rule config, please refer: [Selector and rule config](../../user-guide/admin-usage/selector-and-rule). +- shenyu-admin contextPath plugin config, config contextPath and addPrefix, contextPath defines the value of contextPath, +- and addPrefix defines the prefix that needs to be automatically added when the interface is called. + +![](/img/shenyu/plugin/context-path/plugin-config-en.png) + +## 2.5 Examples + +### 2.5.1 Example set service context path + +#### 2.5.1.1 Refer [Local Deployment](https://shenyu.apache.org/docs/deployment/deployment-local/) 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 Client project config contextPath. + +Client project can directly use [shenyu-examples-http](https://github.com/apache/incubator-shenyu/tree/master/shenyu-examples/shenyu-examples-http), and config contextPath in application.yml. + +![](/img/shenyu/plugin/context-path/client-project-config.png) + +- After the configuration is completed, and start client project, you can see that there is an additional context selector and rule configuration in shenyu-admin. + +![](/img/shenyu/plugin/context-path/context-path-selector-and-rule-en.png) + +#### 2.5.1.5 Call Interface + +![](/img/shenyu/plugin/context-path/invoke-interface.png) + +### 2.5.2 Example add prefix + +#### 2.5.2.1 Refer [Local Deployment](https://shenyu.apache.org/docs/deployment/deployment-local/) 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 Client project config contextPath. + +For client project we can directly use [shenyu-examples-http](https://github.com/apache/incubator-shenyu/tree/master/shenyu-examples/shenyu-examples-http), and config contextPath in application.yml. + +![](/img/shenyu/plugin/context-path/client-project-config.png) + +- After the configuration is completed, start client project, you can see that there is an additional context selector and rule configuration in shenyu-admin. + +![](/img/shenyu/plugin/context-path/context-path-selector-and-rule-en.png) + +#### 2.5.2.5 Config addPrefix + +![](/img/shenyu/plugin/context-path/add-prefix-en.png) + +#### 2.5.2.6 Modify the value of uri in the selector and condition configuration to delete the addPrefix part. + +Since this example uses the service of the http protocol, we need to modify the divide plugin. + +![](/img/shenyu/plugin/context-path/remove-add-prefix-en.png) + +#### 2.5.2.5 Call Interface + +![](/img/shenyu/plugin/context-path/invoke-interface-add-prefix.png) + +# 3. How to disable plugin -## Situation +- In `shenyu-admin` --> BasicConfig --> Plugin --> `contextPath` set Status disable. -* As the name suggests,the context_path plugin redefines the contextPath of URI. -* When the request is matched, the custom `contextPath` is set, then the custom `contextPath` will be intercepted according to the requested Url to obtain the real Url, for example, the request path is `/shenyu/http/order`, - The configured contextPath is `/shenyu/http`, then the requested `url` is `/order`. +![](/img/shenyu/plugin/context-path/disable-en.png)