You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shenyu.apache.org by mi...@apache.org on 2021/09/28 05:52:39 UTC
[incubator-shenyu-website] branch selector-rule created (now
d4c51e4)
This is an automated email from the ASF dual-hosted git repository.
midnight2104 pushed a change to branch selector-rule
in repository https://gitbox.apache.org/repos/asf/incubator-shenyu-website.git.
at d4c51e4 Merge branch 'main' into selector-rule
This branch includes the following new commits:
new fe5b5ed update chinese selector-and-rule.md, add picture.
new 24dc47a update english selector-and-rule.md, add picture.
new d4c51e4 Merge branch 'main' into selector-rule
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[incubator-shenyu-website] 03/03: Merge branch 'main' into
selector-rule
Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
midnight2104 pushed a commit to branch selector-rule
in repository https://gitbox.apache.org/repos/asf/incubator-shenyu-website.git
commit d4c51e4e3100181db9f1a09cc42fbaf7eb254772
Merge: 24dc47a 658a73f
Author: midnight2104 <LL...@163.com>
AuthorDate: Tue Sep 28 13:51:57 2021 +0800
Merge branch 'main' into selector-rule
docs/developer/custom-plugin.md | 32 +-
docs/developer/local-model.md | 543 +++++++++++++++++++++
.../current/developer/custom-plugin.md | 30 +-
.../current/developer/local-model.md | 542 ++++++++++++++++++++
4 files changed, 1140 insertions(+), 7 deletions(-)
[incubator-shenyu-website] 02/03: update english
selector-and-rule.md, add picture.
Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
midnight2104 pushed a commit to branch selector-rule
in repository https://gitbox.apache.org/repos/asf/incubator-shenyu-website.git
commit 24dc47a46fea72fd05e167457271a5c62c484d9d
Author: midnight2104 <LL...@163.com>
AuthorDate: Tue Sep 28 13:51:08 2021 +0800
update english selector-and-rule.md, add picture.
---
docs/user-guide/admin-usage/selector-and-rule.md | 181 ++++++++++++++++++---
.../user-guide/admin-usage/selector-and-rule.md | 181 ++++++++++++++++++---
.../user-guide/admin-usage/selector-and-rule.md | 72 ++++----
.../user-guide/admin-usage/selector-and-rule.md | 181 ++++++++++++++++++---
4 files changed, 513 insertions(+), 102 deletions(-)
diff --git a/docs/user-guide/admin-usage/selector-and-rule.md b/docs/user-guide/admin-usage/selector-and-rule.md
index 2092160..abc3d2d 100644
--- a/docs/user-guide/admin-usage/selector-and-rule.md
+++ b/docs/user-guide/admin-usage/selector-and-rule.md
@@ -103,46 +103,185 @@ For example, add a selector to the `divide` plugin:
* rule advice: combine `uri` condition with `match` the real `uri path` condition as the final filter.
* combine selector means :when the request `uri` is `/http/order/save`, it will be redicted to `127.0.0.1:8080` by `random` method.
-## Condition Explanation
-* uri matching (recommend)
+## Condition Parameter Data
- * uri matching is based on your request uri, the frontend won't change anything before accessing the gateway.
+Conditional parameter Settings in selectors and rules are explained again. Suppose the following is a request header for an `Http` request:
- * the `match` filter method is the same with`springmvc` fuzzy matching.
+```shell
+GET http://localhost:9195/http/order/findById?id=100
+Accept: application/json
+Cookie: shenyu=shenyu_cookie
+MyHeader: custom-header
+```
- * in selector,we recommend to match with the prefix of uri, and use the specific path in rule.
+In `ShenYu` you can set different conditional parameters to get real data from the request information.
- * when changing the match method, the matching field name can be filled randomly, but make sure the match value must be correct.
+- If the condition parameter is `uri`, then the actual data retrieved is `/http/order/findById`;
+- If the condition parameter is `header`, the field name is `MyHeader`, then the actual data retrieved is `custom-header`;
+- If the condition parameter is `query`, the field name is `id`, then the actual data retrieved is `100`;
+- If the condition parameter is `ip`, then the actual data retrieved is `0:0:0:0:0:0:0:1`;
+- If the condition parameter is `host`, then the actual data retrieved is `0:0:0:0:0:0:0:1`;
+- If the condition parameter is `post`, the field name is `contextPath`, then the actual data retrieved is `/http`;
+- If the condition parameter is `cookie`, the field name is `shenyu`, then the actual data retrieved is `shenyu_cookie`;
+- If the condition parameter is `req_method`, then the actual data retrieved is `GET`;
-* header matching
+* `uri`(recommended)
- * header matches with your `http` request header value.
+ * `uri` matches are based on the `uri` in the path you requested, and there is almost no change in the front end when accessing the gateway.
+
+ * When using `match`, the principle is the same as `SpringMVC` fuzzy matching.
+
+ * In selectors, it is recommended to use prefixes in `URI` for matching, while in rules, specific paths are used for matching.
-* query matching
+ * When using this matching method, fill in the value of the matching field, as shown in the figure `/http/**`.
- * it matches the query string in your uri, such as: /test?a=1&&b=2.
+ 
- * so you can add a new condition, choose query method: a = 1.
+* `header`
-* ip matching
+ * The `header` is matched against the field values in your `http` request header.
- * it matches the ip of the http caller.
+ * When using this matching method, you need to fill in the field name and field value. The examples in the figure are `MyHeader` and `custom-header` respectively
- * especially in the waf plugin, if you find some ip is unsafe, you can add a match condition with this ip, then it can't access any more.
+ 
- * if you use nginx proxy before ShenYu, you can get the right ip with refering to [parsing-ip-and-host](../../developer/custom-parsing-ip-and-host)
+* `query`
-* host matching
+ * This matches the query parameters in your `uri`, such as `/test?id=1`, then the matching method can be selected.
- * it matches the host of http caller.
+ * When using this matching method, you need to fill in the field name and field value. The examples in the figure are `id` and 1 respectively.
- * especially in waf plugin, if you find some host is unsafe, you can add a match condition with this host, then it can't access any more.
+ 
- * if you use nginx proxy before ShenYu, you can get the right ip with refering to [parsing-ip-and-host](../../developer/custom-parsing-ip-and-host)
+* `ip`
-* post matching
+ * This is matched against the `http` caller's `ip`.
- * not recommend to use.
+ * Especially in waf plugin, if an `ip` address is found to be attacked, you can add a matching condition, fill in the `ip`, deny the `ip` access.
+ * If you use nginx proxy before ShenYu, you can get the right ip with refering to [parsing-ip-and-host](../../developer/custom-parsing-ip-and-host)
+ * When using this matching method, fill in the value of the matching field, as shown in the example `192.168.236.75`.
+
+ 
+
+
+* `host`
+
+ * This is matched against the `http` caller's `host`.
+
+ * Especially in waf plugin, if an `host` address is found to be attacked, you can add a matching condition, fill in the `host`, deny the `host` access.
+
+ * If you use nginx proxy before ShenYu, you can get the right ip with refering to [parsing-ip-and-host](../../developer/custom-parsing-ip-and-host)
+
+ * When using this matching method, fill in the value of the matching field, as shown in the example `localhost`.
+
+ 
+
+* `post`
+
+ * To get condition parameters from the request context(`org.apache.shenyu.plugin.api.context.ShenyuContext`), reflection is required to get the value of the field, which is not recommended.
+
+ * When using this matching method, the field name and value need to be specified. The examples in the figure are `contextPath` and `/http` respectively.
+
+ 
+
+
+* `cookie`
+
+ * This is matched against the `Cookie` in the `http` caller's request header as a condition parameter.
+
+ * When using this matching method, you need to fill in the field name and field value. The examples in the figure are `shenyu` and `shenyu_cookie` respectively.
+
+ 
+
+* `req_method`
+
+ * This matches the request form of the `http` caller, such as `GET`, `POST`, etc.
+
+ * When using this matching method, fill in the value of the matching field, as shown in the example `GET`.
+
+ 
+
+For a more in-depth understanding of condition parameter fetching, read the source code, package name is `org.apache.shenyu.plugin.base.condition.data`:
+
+|Condition Parameter | Class |
+|:------------------------ |:----- |
+|`uri` |`URIParameterData` |
+|`header` |`HeaderParameterData` |
+|`query` |`QueryParameterData` |
+|`ip` |`IpParameterData` |
+|`host` |`HostParameterData` |
+|`post` |`PostParameterData` |
+|`cookie` |`CookieParameterData` |
+|`req_method` |`RequestMethodParameterData` |
+
+
+## Condition Match Strategy
+
+Condition parameters allow you to retrieve the actual data of the request. How the real data matches the conditional data preset by the selector or rule is realized through the condition match strategy.
+
+
+* `match`
+
+ * `match` supports fuzzy matching (`/**`). Request `/http/order/findById` will match if your selector condition is set as follows.
+
+ 
+
+* `=`
+
+ * `=` means that the requested real data is equal to the preset condition data. If your selector condition is set to request uri equal to `/http/order/findById`, then request`/http/order/findById?id=1` can match it.
+
+ 
+
+* `regex`
+
+ * `regex` means that the requested real data can meet the preset condition of the regular expression to match successfully. Suppose your rule condition is set as follows: the request parameter contains an `id` and is a three-digit number. So request `/http/order/findById?id=900` will match.
+
+ 
+
+* `contains`
+
+ * `contains` means that the requested real data contains the default condition data. Suppose your rule condition is set as follows: request uri contains `findById`. Request `/http/order/findById?id=1` will match.
+
+ 
+
+* `SpEL`
+
+ * `SpEL` means that the requested real data can satisfy the preset `SpEL` expression. Suppose your rule conditions are set as follows: request parameters contain `id` and `id` is greater than `100`. Request `/http/order/findById?id=101` will match.
+
+ 
+
+* `Groovy`
+
+ * The `Groovy` way of expressing the request for real data can satisfy the preset `Groovy` expression. Suppose your rule conditions are set as follows: request parameters include `id`, and `id` equals `100`. Request `/http/order/findById?id=100` will match.
+
+ 
+
+* `TimeBefore`
+
+ * `TimeBefore` indicates that the request time will be matched before the preset condition time. Suppose your rule conditions are set as follows: request parameters contain `date` and `date` is less than `2021-09-26 06:12:10`. Request `/http/order/findById?id=100&date=2021-09-22 06:12:10` will match.
+
+ 
+
+* `TimeAfter`
+
+ * `TimeAfter` indicates that the request time will be matched before the preset condition time. Suppose your rule conditions are set as follows: request parameters contain `date` and `date` is greater than `2021-09-26 06:12:10`. Request `/http/order/findById?id=100&date=2021-09-22 06:12:10` will match.
+
+ 
+
+If you want to further understand conditions matching strategy, please read the source code, the package name is `org.apache.shenyu.plugin.base.condition.judge`:
+
+|Match Strategy | Class |
+|:------------------------ |:----- |
+|`match` |`MatchPredicateJudge` |
+|`=` |`EqualsPredicateJudge` |
+|`regex` |`RegexPredicateJudge` |
+|`contains` |`ContainsPredicateJudge` |
+|`SpEL` |`SpELPredicateJudge` |
+|`Groovy` |`GroovyPredicateJudge` |
+|`TimeBefore` |`TimerBeforePredicateJudge` |
+|`TimeAfter` |`TimerAfterPredicateJudge` |
+
+The examples in this article illustrate the use of selectors and rules. The Settings of specific conditions need to be selected according to actual conditions.
diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/admin-usage/selector-and-rule.md b/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/admin-usage/selector-and-rule.md
index a462151..96de289 100644
--- a/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/admin-usage/selector-and-rule.md
+++ b/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/admin-usage/selector-and-rule.md
@@ -4,22 +4,20 @@ keywords: ["选择器", "规则"]
description: 选择器和规则管理
---
-
本文档将介绍`Apache ShenYu`后台管理系统中选择器和规则的使用,关于选择器和规则的概念及设计请参考 [流量控制](../../design/flow-control)。
-请参考运维部署的内容,选择一种方式启动`shenyu-admin`。比如,通过 [本地部署](../../deployment/deployment-local) 启动`Apache ShenYu`后台管理系统。 启动成功后,可以直接访问 http://localhost:9095 ,默认用户名和密码分别为: `admin` 和 `123456`。
-
+请参考运维部署的内容,选择一种方式启动`shenyu-admin`。比如,通过 [本地部署](../../deployment/deployment-local) 启动`Apache ShenYu`后台管理系统。 启动成功后,可以直接访问 `http://localhost:9095` ,默认用户名和密码分别为: `admin` 和 `123456`。
## 选择器
在插件列表中展示了当前的所有插件,可以给每个插件添加选择器和规则:
-<img src="/img/shenyu/basicConfig/pluginHandle/selector_example.png" width="80%" height="50%" />
+
-例如,给`divide`插件添加选择器:
-<img src="/img/shenyu/basicConfig/pluginHandle/selector_add.png" width="80%" height="80%" />
+例如,给`divide`插件添加选择器:
+
* 选择器详解:
@@ -32,9 +30,9 @@ description: 选择器和规则管理
* `query`:根据 `uri` 的查询条件来进行筛选流量。
* `ip`:根据请求的真实 `ip` 来筛选流量。
* `host`:根据请求的真实 `host` 来筛选流量。
- * `post`:不建议使用。
+ * `post`:根据请求上下文获取参数,不建议使用。
* `cookie`:根据请求的 `cookie` 来筛选流量。
- * `req_method`:根据请求的 `req_method` 来筛选流量。
+ * `req_method`:根据请求的方式来筛选流量。
* 条件匹配:
* `match`:模糊匹配,建议和`uri`条件搭配,支持 `restful` 风格的匹配。(`/test/**`)
* `=`:前后值相等,才能匹配。
@@ -57,7 +55,7 @@ description: 选择器和规则管理
## 规则
-<img src="/img/shenyu/basicConfig/pluginHandle/rule_handle.png" width="80%" height="80%" />
+
* 当流量经过选择器匹配成功之后,会进入规则来进行最终的流量匹配。
@@ -96,11 +94,30 @@ description: 选择器和规则管理
联合选择器,我们来表述一下:当一个请求的 `uri` 为 `/http/order/save`,会通过 `random` 的方式,转发到 `127.0.0.1:8080` 机器上。
-## 条件详解
+## 条件参数
+
+对选择器和规则中的条件参数设置再次进行解释。假如下面是一个 `HTTP` 请求的请求头:
+
+```shell
+GET http://localhost:9195/http/order/findById?id=100
+Accept: application/json
+Cookie: shenyu=shenyu_cookie
+MyHeader: custom-header
+```
-对选择器和规则中的条件设置再次进行解释。
+在`ShenYu`中可以通过设置不同的条件参数从请求信息中获取真实数据。
-* `uri` 匹配 (推荐)
+- 如果条件参数是`uri`,那么获取到的真实数据是 `/http/order/findById`;
+- 如果条件参数是`header`,字段名称是`MyHeader`,那么获取到的真实数据是 `custom-header`;
+- 如果条件参数是`query`,字段名称是`id`,那么获取到的真实数据是 `100`;
+- 如果条件参数是`ip`,那么获取到的真实数据 `0:0:0:0:0:0:0:1`;
+- 如果条件参数是`host`,那么获取到的真实数据是 `0:0:0:0:0:0:0:1`;
+- 如果条件参数是`post`,字段名称是`contextPath`,那么获取到的真实数据是 `/http`;
+- 如果条件参数是`cookie`,字段名称是`shenyu`,那么获取到的真实数据是 `shenyu_cookie`;
+- 如果条件参数是`req_method`,那么获取到的真实数据是 `GET`。
+
+
+* `uri` (推荐)
* `uri` 匹配是根据你请求路径中的 `uri` 来进行匹配,在接入网关的时候,前端几乎不用做任何更改。
@@ -108,35 +125,153 @@ description: 选择器和规则管理
* 在选择器中,推荐使用 `uri` 中的前缀来进行匹配,而在规则中,则使用具体路径来进行匹配。
- * 该匹配方式的时候,在匹配字段名称可以任意填写,匹配字段值需要正确填写。
+ * 使用该匹配方式的时候,填写匹配字段的值,图中的示例是`/http/**`。
-* `header` 匹配
+ 
+
+* `header`
* `header` 是根据你的 `http` 请求头中的字段值来匹配。
-* `query` 匹配
+ * 使用该匹配方式的时候,需要填写字段名称和字段值,图中的示例分别是`MyHeader`和`custom-header`。
+
+ 
- * 这个是根据你的 `uri` 中的查询参数来进行匹配,比如 `/test?a=1&b=2` ,那么可以选择该匹配方式。
+* `query`
- * 上述就可以新增一个条件,选取 `query` 方式, `a = 1`。
+ * 这个是根据你的 `uri` 中的查询参数来进行匹配,比如 `/test?id=1`,那么可以选择该匹配方式。
-* `ip`匹配
+ * 使用该匹配方式的时候,需要填写字段名称和字段值,图中的示例分别是`id`和`1`。
+
+ 
+
+* `ip`
* 这个是根据 `http` 调用方的 `ip` 来进行匹配。
* 尤其是在 `waf` 插件里面,如果发现一个 `ip`地址有攻击,可以新增一条匹配条件,填上该 `ip`,拒绝该 `ip` 的访问。
- * 如果在 `Apache ShenYu` 前面使用了 `nginx` 代理,为了获取正确的 `ip`,可以参考 [自定义解析IP与Host](../../developer/custom-parsing-ip-and-host)
+ * 如果在 `Apache ShenYu` 前面使用了 `nginx` 代理,为了获取正确的 `ip`,可以参考 [自定义解析IP与Host](../../developer/custom-parsing-ip-and-host) 。
+
+ * 使用该匹配方式的时候,填写匹配字段的值,图中的示例是`192.168.236.75`。
+
+ 
-* `host` 匹配
+
+* `host`
* 这个是根据 `http` 调用方的 `host` 来进行匹配。
* 尤其是在 `waf` 插件里面,如果发现一个 `host` 地址有攻击,可以新增一条匹配条件,填上该 `host`,拒绝该 `host` 的访问。
- * 如果在 `Apache ShenYu` 前面使用了 `nginx` 代理,为了获取正确的 `host`,可以参考 [自定义解析IP与Host](../../developer/custom-parsing-ip-and-host)
+ * 如果在 `Apache ShenYu` 前面使用了 `nginx` 代理,为了获取正确的 `host`,可以参考 [自定义解析IP与Host](../../developer/custom-parsing-ip-and-host) 。
+
+ * 使用该匹配方式的时候,填写匹配字段的值,图中的示例是`localhost`。
+
+ 
+
+* `post`
+
+ * 从请求上下文(`org.apache.shenyu.plugin.api.context.ShenyuContext`)中获取条件参数,需要通过反射获取字段的值,不推荐使用此方式。
+
+ * 使用该匹配方式的时候,需要填写字段名称和字段值,图中的示例分别是`contextPath`和`/http`。
+
+ 
+
+
+* `cookie`
+
+ * 这个是根据 `http` 调用方的请求头中`Cookie`作为条件参数进行匹配。
+
+ * 使用该匹配方式的时候,需要填写字段名称和字段值,图中的示例分别是`shenyu`和`shenyu_cookie`。
+
+ 
+
+* `req_method`
+
+ * 这个是根据 `http` 调用方的请求形式来进行匹配,比如`GET`、`POST`等。
+
+ * 使用该匹配方式的时候,填写匹配字段的值,图中的示例是`GET`。
+
+ 
+
+如果想更深入理解条件参数的获取,请阅读相关源码,包名是`org.apache.shenyu.plugin.base.condition.data`:
+
+|条件参数 | 源码类 |
+|:------------------------ |:----- |
+|`uri` |`URIParameterData` |
+|`header` |`HeaderParameterData` |
+|`query` |`QueryParameterData` |
+|`ip` |`IpParameterData` |
+|`host` |`HostParameterData` |
+|`post` |`PostParameterData` |
+|`cookie` |`CookieParameterData` |
+|`req_method` |`RequestMethodParameterData` |
+
+
+## 条件匹配策略
+
+通过条件参数能够获取到请求的真实数据。真实数据如何匹配上选择器或规则预设的条件数据,是通过条件匹配策略来实现。
+
+* `match`
+
+ `match` 的方式支持模糊匹配(`/**`)。假如你的选择器条件设置如下,那么请求 `/http/order/findById` 就可以匹配上。
+
+ 
+
+* `=`
+
+ `=` 的方式表示请求的真实数据和预设的条件数据相等。假如你的选择器条件设置如下:请求`uri`等于`/http/order/findById`,那么请求 `/http/order/findById?id=1` 就可以匹配上。
+
+ 
+
+* `regex`
+
+ `regex` 的方式表示请求的真实数据能够满足预设条件的正则表达式才能匹配成功。假如你的规则条件设置如下:请求参数中包含`id`,并且是3位数字。那么请求 `/http/order/findById?id=900` 就可以匹配上。
+
+ 
+
+* `contains`
+
+ `contains` 的方式表示请求的真实数据包含预设的条件数据。假如你的规则条件设置如下:请求`uri`中包含`findById`。那么请求 `/http/order/findById?id=1` 就可以匹配上。
+
+ 
+
+* `SpEL`
+
+ `SpEL` 的方式表示请求的真实数据能够满足预设的`SpEL`表达式。假如你的规则条件设置如下:请求参数中包含`id`,并且`id`大于`100`。那么请求 `/http/order/findById?id=101` 就可以匹配上。
+
+ 
+
+* `Groovy`
+
+ `Groovy` 的方式表示请求的真实数据能够满足预设的`Groovy`表达式。假如你的规则条件设置如下:请求参数中包含`id`,并且`id`等`100`。那么请求 `/http/order/findById?id=100` 就可以匹配上。
+
+ 
+
+* `TimeBefore`
+
+ `TimeBefore` 的方式表示请求时间在预设的条件时间之前才能匹配成功。假如你的规则条件设置如下:请求参数中包含`date`,并且`date`小于`2021-09-26 06:12:10`。那么请求 `/http/order/findById?id=100&date=2021-09-22 06:12:10` 就可以匹配上。
+
+ 
+
+* `TimeAfter`
+
+ `TimeAfter` 的方式表示请求时间在预设的条件时间之后才能匹配成功。假如你的规则条件设置如下:请求参数中包含`date`,并且`date`大于`2021-09-26 06:12:10`。那么请求 `/http/order/findById?id=100&date=2021-09-29 06:12:10` 就可以匹配上。
+
+ 
-* `post` 匹配
+如果想更深入理解条件匹配策略,请阅读相关源码,包名是`org.apache.shenyu.plugin.base.condition.judge`:
- * 不推荐使用。
+|匹配策略 | 源码类 |
+|:------------------------ |:----- |
+|`match` |`MatchPredicateJudge` |
+|`=` |`EqualsPredicateJudge` |
+|`regex` |`RegexPredicateJudge` |
+|`contains` |`ContainsPredicateJudge` |
+|`SpEL` |`SpELPredicateJudge` |
+|`Groovy` |`GroovyPredicateJudge` |
+|`TimeBefore` |`TimerBeforePredicateJudge` |
+|`TimeAfter` |`TimerAfterPredicateJudge` |
+文中的示例是为了说明选择器和规则的使用,具体条件的设置需要根据实际情况选择。
diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-2.4.0/user-guide/admin-usage/selector-and-rule.md b/i18n/zh/docusaurus-plugin-content-docs/version-2.4.0/user-guide/admin-usage/selector-and-rule.md
index 32cdb01..dbc9a03 100644
--- a/i18n/zh/docusaurus-plugin-content-docs/version-2.4.0/user-guide/admin-usage/selector-and-rule.md
+++ b/i18n/zh/docusaurus-plugin-content-docs/version-2.4.0/user-guide/admin-usage/selector-and-rule.md
@@ -4,12 +4,10 @@ keywords: ["选择器", "规则"]
description: 选择器和规则管理
---
-
本文档将介绍`Apache ShenYu`后台管理系统中选择器和规则的使用,关于选择器和规则的概念及设计请参考 [流量控制](../../design/flow-control)。
请参考运维部署的内容,选择一种方式启动`shenyu-admin`。比如,通过 [本地部署](../../deployment/deployment-local) 启动`Apache ShenYu`后台管理系统。 启动成功后,可以直接访问 `http://localhost:9095` ,默认用户名和密码分别为: `admin` 和 `123456`。
-
## 选择器
在插件列表中展示了当前的所有插件,可以给每个插件添加选择器和规则:
@@ -119,7 +117,7 @@ MyHeader: custom-header
- 如果条件参数是`req_method`,那么获取到的真实数据是 `GET`。
-* `uri` 匹配 (推荐)
+* `uri` (推荐)
* `uri` 匹配是根据你请求路径中的 `uri` 来进行匹配,在接入网关的时候,前端几乎不用做任何更改。
@@ -131,7 +129,7 @@ MyHeader: custom-header

-* `header` 匹配
+* `header`
* `header` 是根据你的 `http` 请求头中的字段值来匹配。
@@ -139,7 +137,7 @@ MyHeader: custom-header

-* `query` 匹配
+* `query`
* 这个是根据你的 `uri` 中的查询参数来进行匹配,比如 `/test?id=1`,那么可以选择该匹配方式。
@@ -147,7 +145,7 @@ MyHeader: custom-header

-* `ip`匹配
+* `ip`
* 这个是根据 `http` 调用方的 `ip` 来进行匹配。
@@ -160,7 +158,7 @@ MyHeader: custom-header

-* `host` 匹配
+* `host`
* 这个是根据 `http` 调用方的 `host` 来进行匹配。
@@ -172,7 +170,7 @@ MyHeader: custom-header

-* `post` 匹配
+* `post`
* 从请求上下文(`org.apache.shenyu.plugin.api.context.ShenyuContext`)中获取条件参数,需要通过反射获取字段的值,不推荐使用此方式。
@@ -181,7 +179,7 @@ MyHeader: custom-header

-* `cookie` 匹配
+* `cookie`
* 这个是根据 `http` 调用方的请求头中`Cookie`作为条件参数进行匹配。
@@ -189,7 +187,7 @@ MyHeader: custom-header

-* `req_method` 匹配
+* `req_method`
* 这个是根据 `http` 调用方的请求形式来进行匹配,比如`GET`、`POST`等。
@@ -199,65 +197,65 @@ MyHeader: custom-header
如果想更深入理解条件参数的获取,请阅读相关源码,包名是`org.apache.shenyu.plugin.base.condition.data`:
-|匹配策略 | 源码类 |
+|条件参数 | 源码类 |
|:------------------------ |:----- |
-|`uri` 匹配 |`URIParameterData` |
-|`header` 匹配 |`HeaderParameterData` |
-|`query` 匹配 |`QueryParameterData` |
-|`ip`匹配 |`IpParameterData` |
-|`host`匹配 |`HostParameterData` |
-|`post` 匹配 |`PostParameterData` |
-|`cookie` 匹配 |`CookieParameterData` |
-|`req_method` 匹配 |`RequestMethodParameterData` |
+|`uri` |`URIParameterData` |
+|`header` |`HeaderParameterData` |
+|`query` |`QueryParameterData` |
+|`ip` |`IpParameterData` |
+|`host` |`HostParameterData` |
+|`post` |`PostParameterData` |
+|`cookie` |`CookieParameterData` |
+|`req_method` |`RequestMethodParameterData` |
## 条件匹配策略
通过条件参数能够获取到请求的真实数据。真实数据如何匹配上选择器或规则预设的条件数据,是通过条件匹配策略来实现。
-* `match` 匹配策略
+* `match`
`match` 的方式支持模糊匹配(`/**`)。假如你的选择器条件设置如下,那么请求 `/http/order/findById` 就可以匹配上。

-* `=` 匹配策略
+* `=`
`=` 的方式表示请求的真实数据和预设的条件数据相等。假如你的选择器条件设置如下:请求`uri`等于`/http/order/findById`,那么请求 `/http/order/findById?id=1` 就可以匹配上。

-* `regex` 匹配策略
+* `regex`
`regex` 的方式表示请求的真实数据能够满足预设条件的正则表达式才能匹配成功。假如你的规则条件设置如下:请求参数中包含`id`,并且是3位数字。那么请求 `/http/order/findById?id=900` 就可以匹配上。

-* `contains` 匹配策略
+* `contains`
`contains` 的方式表示请求的真实数据包含预设的条件数据。假如你的规则条件设置如下:请求`uri`中包含`findById`。那么请求 `/http/order/findById?id=1` 就可以匹配上。

-* `SpEL` 匹配策略
+* `SpEL`
`SpEL` 的方式表示请求的真实数据能够满足预设的`SpEL`表达式。假如你的规则条件设置如下:请求参数中包含`id`,并且`id`大于`100`。那么请求 `/http/order/findById?id=101` 就可以匹配上。

-* `Groovy` 匹配策略
+* `Groovy`
`Groovy` 的方式表示请求的真实数据能够满足预设的`Groovy`表达式。假如你的规则条件设置如下:请求参数中包含`id`,并且`id`等`100`。那么请求 `/http/order/findById?id=100` 就可以匹配上。

-* `TimeBefore` 匹配策略
+* `TimeBefore`
`TimeBefore` 的方式表示请求时间在预设的条件时间之前才能匹配成功。假如你的规则条件设置如下:请求参数中包含`date`,并且`date`小于`2021-09-26 06:12:10`。那么请求 `/http/order/findById?id=100&date=2021-09-22 06:12:10` 就可以匹配上。

-* `TimeAfter` 匹配策略
+* `TimeAfter`
`TimeAfter` 的方式表示请求时间在预设的条件时间之后才能匹配成功。假如你的规则条件设置如下:请求参数中包含`date`,并且`date`大于`2021-09-26 06:12:10`。那么请求 `/http/order/findById?id=100&date=2021-09-29 06:12:10` 就可以匹配上。
@@ -267,13 +265,13 @@ MyHeader: custom-header
|匹配策略 | 源码类 |
|:------------------------ |:----- |
-|`match` 匹配策略 |`MatchPredicateJudge` |
-|`=` 匹配策略 |`EqualsPredicateJudge` |
-|`regex` 匹配策略 |`RegexPredicateJudge` |
-|`contains` 匹配策略 |`ContainsPredicateJudge` |
-|`SpEL` 匹配策略 |`SpELPredicateJudge` |
-|`Groovy` 匹配策略 |`GroovyPredicateJudge` |
-|`TimeBefore` 匹配策略 |`TimerBeforePredicateJudge` |
-|`TimeAfter` 匹配策略 |`TimerAfterPredicateJudge` |
-
-
+|`match` |`MatchPredicateJudge` |
+|`=` |`EqualsPredicateJudge` |
+|`regex` |`RegexPredicateJudge` |
+|`contains` |`ContainsPredicateJudge` |
+|`SpEL` |`SpELPredicateJudge` |
+|`Groovy` |`GroovyPredicateJudge` |
+|`TimeBefore` |`TimerBeforePredicateJudge` |
+|`TimeAfter` |`TimerAfterPredicateJudge` |
+
+文中的示例是为了说明选择器和规则的使用,具体条件的设置需要根据实际情况选择。
diff --git a/versioned_docs/version-2.4.0/user-guide/admin-usage/selector-and-rule.md b/versioned_docs/version-2.4.0/user-guide/admin-usage/selector-and-rule.md
index 2092160..46c376e 100644
--- a/versioned_docs/version-2.4.0/user-guide/admin-usage/selector-and-rule.md
+++ b/versioned_docs/version-2.4.0/user-guide/admin-usage/selector-and-rule.md
@@ -103,46 +103,185 @@ For example, add a selector to the `divide` plugin:
* rule advice: combine `uri` condition with `match` the real `uri path` condition as the final filter.
* combine selector means :when the request `uri` is `/http/order/save`, it will be redicted to `127.0.0.1:8080` by `random` method.
-## Condition Explanation
-* uri matching (recommend)
+## Condition Parameter Data
- * uri matching is based on your request uri, the frontend won't change anything before accessing the gateway.
+Conditional parameter Settings in selectors and rules are explained again. Suppose the following is a request header for an `Http` request:
- * the `match` filter method is the same with`springmvc` fuzzy matching.
+```shell
+GET http://localhost:9195/http/order/findById?id=100
+Accept: application/json
+Cookie: shenyu=shenyu_cookie
+MyHeader: custom-header
+```
- * in selector,we recommend to match with the prefix of uri, and use the specific path in rule.
+In `ShenYu` you can set different conditional parameters to get real data from the request information.
- * when changing the match method, the matching field name can be filled randomly, but make sure the match value must be correct.
+- If the condition parameter is `uri`, then the actual data retrieved is `/http/order/findById`;
+- If the condition parameter is `header`, the field name is `MyHeader`, then the actual data retrieved is `custom-header`;
+- If the condition parameter is `query`, the field name is `id`, then the actual data retrieved is `100`;
+- If the condition parameter is `ip`, then the actual data retrieved is `0:0:0:0:0:0:0:1`;
+- If the condition parameter is `host`, then the actual data retrieved is `0:0:0:0:0:0:0:1`;
+- If the condition parameter is `post`, the field name is `contextPath`, then the actual data retrieved is `/http`;
+- If the condition parameter is `cookie`, the field name is `shenyu`, then the actual data retrieved is `shenyu_cookie`;
+- If the condition parameter is `req_method`, then the actual data retrieved is `GET`;
-* header matching
+* `uri`(recommended)
- * header matches with your `http` request header value.
+ * `uri` matches are based on the `uri` in the path you requested, and there is almost no change in the front end when accessing the gateway.
-* query matching
+ * When using `match`, the principle is the same as `SpringMVC` fuzzy matching.
- * it matches the query string in your uri, such as: /test?a=1&&b=2.
+ * In selectors, it is recommended to use prefixes in `URI` for matching, while in rules, specific paths are used for matching.
- * so you can add a new condition, choose query method: a = 1.
+ * When using this matching method, fill in the value of the matching field, as shown in the figure `/http/**`.
-* ip matching
+ 
- * it matches the ip of the http caller.
+* `header`
- * especially in the waf plugin, if you find some ip is unsafe, you can add a match condition with this ip, then it can't access any more.
+ * The `header` is matched against the field values in your `http` request header.
- * if you use nginx proxy before ShenYu, you can get the right ip with refering to [parsing-ip-and-host](../../developer/custom-parsing-ip-and-host)
+ * When using this matching method, you need to fill in the field name and field value. The examples in the figure are `MyHeader` and `custom-header` respectively
-* host matching
+ 
- * it matches the host of http caller.
+* `query`
- * especially in waf plugin, if you find some host is unsafe, you can add a match condition with this host, then it can't access any more.
+ * This matches the query parameters in your `uri`, such as `/test?id=1`, then the matching method can be selected.
- * if you use nginx proxy before ShenYu, you can get the right ip with refering to [parsing-ip-and-host](../../developer/custom-parsing-ip-and-host)
+ * When using this matching method, you need to fill in the field name and field value. The examples in the figure are `id` and 1 respectively.
-* post matching
+ 
- * not recommend to use.
+* `ip`
+ * This is matched against the `http` caller's `ip`.
+ * Especially in waf plugin, if an `ip` address is found to be attacked, you can add a matching condition, fill in the `ip`, deny the `ip` access.
+
+ * If you use nginx proxy before ShenYu, you can get the right ip with refering to [parsing-ip-and-host](../../developer/custom-parsing-ip-and-host)
+
+ * When using this matching method, fill in the value of the matching field, as shown in the example `192.168.236.75`.
+
+ 
+
+
+* `host`
+
+ * This is matched against the `http` caller's `host`.
+
+ * Especially in waf plugin, if an `host` address is found to be attacked, you can add a matching condition, fill in the `host`, deny the `host` access.
+
+ * If you use nginx proxy before ShenYu, you can get the right ip with refering to [parsing-ip-and-host](../../developer/custom-parsing-ip-and-host)
+
+ * When using this matching method, fill in the value of the matching field, as shown in the example `localhost`.
+
+ 
+
+* `post`
+
+ * To get condition parameters from the request context(`org.apache.shenyu.plugin.api.context.ShenyuContext`), reflection is required to get the value of the field, which is not recommended.
+
+ * When using this matching method, the field name and value need to be specified. The examples in the figure are `contextPath` and `/http` respectively.
+
+ 
+
+
+* `cookie`
+
+ * This is matched against the `Cookie` in the `http` caller's request header as a condition parameter.
+
+ * When using this matching method, you need to fill in the field name and field value. The examples in the figure are `shenyu` and `shenyu_cookie` respectively.
+
+ 
+
+* `req_method`
+
+ * This matches the request form of the `http` caller, such as `GET`, `POST`, etc.
+
+ * When using this matching method, fill in the value of the matching field, as shown in the example `GET`.
+
+ 
+
+For a more in-depth understanding of condition parameter fetching, read the source code, package name is `org.apache.shenyu.plugin.base.condition.data`:
+
+|Condition Parameter | Class |
+|:------------------------ |:----- |
+|`uri` |`URIParameterData` |
+|`header` |`HeaderParameterData` |
+|`query` |`QueryParameterData` |
+|`ip` |`IpParameterData` |
+|`host` |`HostParameterData` |
+|`post` |`PostParameterData` |
+|`cookie` |`CookieParameterData` |
+|`req_method` |`RequestMethodParameterData` |
+
+
+## Condition Match Strategy
+
+Condition parameters allow you to retrieve the actual data of the request. How the real data matches the conditional data preset by the selector or rule is realized through the condition match strategy.
+
+
+* `match`
+
+ * `match` supports fuzzy matching (`/**`). Request `/http/order/findById` will match if your selector condition is set as follows.
+
+ 
+
+* `=`
+
+ * `=` means that the requested real data is equal to the preset condition data. If your selector condition is set to request uri equal to `/http/order/findById`, then request`/http/order/findById?id=1` can match it.
+
+ 
+
+* `regex`
+
+ * `regex` means that the requested real data can meet the preset condition of the regular expression to match successfully. Suppose your rule condition is set as follows: the request parameter contains an `id` and is a three-digit number. So request `/http/order/findById?id=900` will match.
+
+ 
+
+* `contains`
+
+ * `contains` means that the requested real data contains the default condition data. Suppose your rule condition is set as follows: request uri contains `findById`. Request `/http/order/findById?id=1` will match.
+
+ 
+
+* `SpEL`
+
+ * `SpEL` means that the requested real data can satisfy the preset `SpEL` expression. Suppose your rule conditions are set as follows: request parameters contain `id` and `id` is greater than `100`. Request `/http/order/findById?id=101` will match.
+
+ 
+
+* `Groovy`
+
+ * The `Groovy` way of expressing the request for real data can satisfy the preset `Groovy` expression. Suppose your rule conditions are set as follows: request parameters include `id`, and `id` equals `100`. Request `/http/order/findById?id=100` will match.
+
+ 
+
+* `TimeBefore`
+
+ * `TimeBefore` indicates that the request time will be matched before the preset condition time. Suppose your rule conditions are set as follows: request parameters contain `date` and `date` is less than `2021-09-26 06:12:10`. Request `/http/order/findById?id=100&date=2021-09-22 06:12:10` will match.
+
+ 
+
+* `TimeAfter`
+
+ * `TimeAfter` indicates that the request time will be matched before the preset condition time. Suppose your rule conditions are set as follows: request parameters contain `date` and `date` is greater than `2021-09-26 06:12:10`. Request `/http/order/findById?id=100&date=2021-09-22 06:12:10` will match.
+
+ 
+
+If you want to further understand conditions matching strategy, please read the source code, the package name is `org.apache.shenyu.plugin.base.condition.judge`:
+
+|Match Strategy | Class |
+|:------------------------ |:----- |
+|`match` |`MatchPredicateJudge` |
+|`=` |`EqualsPredicateJudge` |
+|`regex` |`RegexPredicateJudge` |
+|`contains` |`ContainsPredicateJudge` |
+|`SpEL` |`SpELPredicateJudge` |
+|`Groovy` |`GroovyPredicateJudge` |
+|`TimeBefore` |`TimerBeforePredicateJudge` |
+|`TimeAfter` |`TimerAfterPredicateJudge` |
+
+The examples in this article illustrate the use of selectors and rules. The Settings of specific conditions need to be selected according to actual conditions.
[incubator-shenyu-website] 01/03: update chinese
selector-and-rule.md, add picture.
Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
midnight2104 pushed a commit to branch selector-rule
in repository https://gitbox.apache.org/repos/asf/incubator-shenyu-website.git
commit fe5b5ed3a8c067c048618e016ee4a3379766614f
Author: midnight2104 <LL...@163.com>
AuthorDate: Mon Sep 27 13:47:37 2021 +0800
update chinese selector-and-rule.md, add picture.
---
.../user-guide/admin-usage/selector-and-rule.md | 169 +++++++++++++++++++--
.../selectorRule/parameter-data-cookie-en.png | Bin 0 -> 76026 bytes
.../selectorRule/parameter-data-cookie-zh.png | Bin 0 -> 84413 bytes
.../selectorRule/parameter-data-header-en.png | Bin 0 -> 75966 bytes
.../selectorRule/parameter-data-header-zh.png | Bin 0 -> 85035 bytes
.../selectorRule/parameter-data-host-en.png | Bin 0 -> 73543 bytes
.../selectorRule/parameter-data-host-zh.png | Bin 0 -> 82194 bytes
.../selectorRule/parameter-data-ip-en.png | Bin 0 -> 75271 bytes
.../selectorRule/parameter-data-ip-zh.png | Bin 0 -> 83849 bytes
.../selectorRule/parameter-data-post-en.png | Bin 0 -> 74775 bytes
.../selectorRule/parameter-data-post-zh.png | Bin 0 -> 83924 bytes
.../selectorRule/parameter-data-query-en.png | Bin 0 -> 74257 bytes
.../selectorRule/parameter-data-query-zh.png | Bin 0 -> 82546 bytes
.../selectorRule/parameter-data-req_method-en.png | Bin 0 -> 74230 bytes
.../selectorRule/parameter-data-req_method-zh.png | Bin 0 -> 83281 bytes
.../selectorRule/parameter-data-uri-en.png | Bin 0 -> 73930 bytes
.../selectorRule/parameter-data-uri-zh.png | Bin 0 -> 83019 bytes
.../selectorRule/predicate-judge-contains-en.png | Bin 0 -> 65205 bytes
.../selectorRule/predicate-judge-contains-zh.png | Bin 0 -> 67942 bytes
.../selectorRule/predicate-judge-equals-en.png | Bin 0 -> 65232 bytes
.../selectorRule/predicate-judge-equals-zh.png | Bin 0 -> 68359 bytes
.../selectorRule/predicate-judge-groovy-en.png | Bin 0 -> 67118 bytes
.../selectorRule/predicate-judge-groovy-zh.png | Bin 0 -> 69809 bytes
.../selectorRule/predicate-judge-match-en.png | Bin 0 -> 73779 bytes
.../selectorRule/predicate-judge-match-zh.png | Bin 0 -> 82500 bytes
.../selectorRule/predicate-judge-regex-en.png | Bin 0 -> 65776 bytes
.../selectorRule/predicate-judge-regex-zh.png | Bin 0 -> 68428 bytes
.../selectorRule/predicate-judge-spel-en.png | Bin 0 -> 66115 bytes
.../selectorRule/predicate-judge-spel-zh.png | Bin 0 -> 68582 bytes
.../selectorRule/predicate-judge-timeafter-en.png | Bin 0 -> 68792 bytes
.../selectorRule/predicate-judge-timeafter-zh.png | Bin 0 -> 70723 bytes
.../selectorRule/predicate-judge-timebefore-en.png | Bin 0 -> 67614 bytes
.../selectorRule/predicate-judge-timebefore-zh.png | Bin 0 -> 70279 bytes
33 files changed, 153 insertions(+), 16 deletions(-)
diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-2.4.0/user-guide/admin-usage/selector-and-rule.md b/i18n/zh/docusaurus-plugin-content-docs/version-2.4.0/user-guide/admin-usage/selector-and-rule.md
index a462151..32cdb01 100644
--- a/i18n/zh/docusaurus-plugin-content-docs/version-2.4.0/user-guide/admin-usage/selector-and-rule.md
+++ b/i18n/zh/docusaurus-plugin-content-docs/version-2.4.0/user-guide/admin-usage/selector-and-rule.md
@@ -7,19 +7,19 @@ description: 选择器和规则管理
本文档将介绍`Apache ShenYu`后台管理系统中选择器和规则的使用,关于选择器和规则的概念及设计请参考 [流量控制](../../design/flow-control)。
-请参考运维部署的内容,选择一种方式启动`shenyu-admin`。比如,通过 [本地部署](../../deployment/deployment-local) 启动`Apache ShenYu`后台管理系统。 启动成功后,可以直接访问 http://localhost:9095 ,默认用户名和密码分别为: `admin` 和 `123456`。
+请参考运维部署的内容,选择一种方式启动`shenyu-admin`。比如,通过 [本地部署](../../deployment/deployment-local) 启动`Apache ShenYu`后台管理系统。 启动成功后,可以直接访问 `http://localhost:9095` ,默认用户名和密码分别为: `admin` 和 `123456`。
## 选择器
在插件列表中展示了当前的所有插件,可以给每个插件添加选择器和规则:
-<img src="/img/shenyu/basicConfig/pluginHandle/selector_example.png" width="80%" height="50%" />
+
-例如,给`divide`插件添加选择器:
-<img src="/img/shenyu/basicConfig/pluginHandle/selector_add.png" width="80%" height="80%" />
+例如,给`divide`插件添加选择器:
+
* 选择器详解:
@@ -32,9 +32,9 @@ description: 选择器和规则管理
* `query`:根据 `uri` 的查询条件来进行筛选流量。
* `ip`:根据请求的真实 `ip` 来筛选流量。
* `host`:根据请求的真实 `host` 来筛选流量。
- * `post`:不建议使用。
+ * `post`:根据请求上下文获取参数,不建议使用。
* `cookie`:根据请求的 `cookie` 来筛选流量。
- * `req_method`:根据请求的 `req_method` 来筛选流量。
+ * `req_method`:根据请求的方式来筛选流量。
* 条件匹配:
* `match`:模糊匹配,建议和`uri`条件搭配,支持 `restful` 风格的匹配。(`/test/**`)
* `=`:前后值相等,才能匹配。
@@ -57,7 +57,7 @@ description: 选择器和规则管理
## 规则
-<img src="/img/shenyu/basicConfig/pluginHandle/rule_handle.png" width="80%" height="80%" />
+
* 当流量经过选择器匹配成功之后,会进入规则来进行最终的流量匹配。
@@ -96,9 +96,28 @@ description: 选择器和规则管理
联合选择器,我们来表述一下:当一个请求的 `uri` 为 `/http/order/save`,会通过 `random` 的方式,转发到 `127.0.0.1:8080` 机器上。
-## 条件详解
+## 条件参数
+
+对选择器和规则中的条件参数设置再次进行解释。假如下面是一个 `HTTP` 请求的请求头:
+
+```shell
+GET http://localhost:9195/http/order/findById?id=100
+Accept: application/json
+Cookie: shenyu=shenyu_cookie
+MyHeader: custom-header
+```
+
+在`ShenYu`中可以通过设置不同的条件参数从请求信息中获取真实数据。
+
+- 如果条件参数是`uri`,那么获取到的真实数据是 `/http/order/findById`;
+- 如果条件参数是`header`,字段名称是`MyHeader`,那么获取到的真实数据是 `custom-header`;
+- 如果条件参数是`query`,字段名称是`id`,那么获取到的真实数据是 `100`;
+- 如果条件参数是`ip`,那么获取到的真实数据 `0:0:0:0:0:0:0:1`;
+- 如果条件参数是`host`,那么获取到的真实数据是 `0:0:0:0:0:0:0:1`;
+- 如果条件参数是`post`,字段名称是`contextPath`,那么获取到的真实数据是 `/http`;
+- 如果条件参数是`cookie`,字段名称是`shenyu`,那么获取到的真实数据是 `shenyu_cookie`;
+- 如果条件参数是`req_method`,那么获取到的真实数据是 `GET`。
-对选择器和规则中的条件设置再次进行解释。
* `uri` 匹配 (推荐)
@@ -108,17 +127,25 @@ description: 选择器和规则管理
* 在选择器中,推荐使用 `uri` 中的前缀来进行匹配,而在规则中,则使用具体路径来进行匹配。
- * 该匹配方式的时候,在匹配字段名称可以任意填写,匹配字段值需要正确填写。
+ * 使用该匹配方式的时候,填写匹配字段的值,图中的示例是`/http/**`。
+
+ 
* `header` 匹配
- * `header` 是根据你的 `http` 请求头中的字段值来匹配。
+ * `header` 是根据你的 `http` 请求头中的字段值来匹配。
+
+ * 使用该匹配方式的时候,需要填写字段名称和字段值,图中的示例分别是`MyHeader`和`custom-header`。
+
+ 
* `query` 匹配
- * 这个是根据你的 `uri` 中的查询参数来进行匹配,比如 `/test?a=1&b=2` ,那么可以选择该匹配方式。
+ * 这个是根据你的 `uri` 中的查询参数来进行匹配,比如 `/test?id=1`,那么可以选择该匹配方式。
- * 上述就可以新增一个条件,选取 `query` 方式, `a = 1`。
+ * 使用该匹配方式的时候,需要填写字段名称和字段值,图中的示例分别是`id`和`1`。
+
+ 
* `ip`匹配
@@ -126,7 +153,12 @@ description: 选择器和规则管理
* 尤其是在 `waf` 插件里面,如果发现一个 `ip`地址有攻击,可以新增一条匹配条件,填上该 `ip`,拒绝该 `ip` 的访问。
- * 如果在 `Apache ShenYu` 前面使用了 `nginx` 代理,为了获取正确的 `ip`,可以参考 [自定义解析IP与Host](../../developer/custom-parsing-ip-and-host)
+ * 如果在 `Apache ShenYu` 前面使用了 `nginx` 代理,为了获取正确的 `ip`,可以参考 [自定义解析IP与Host](../../developer/custom-parsing-ip-and-host) 。
+
+ * 使用该匹配方式的时候,填写匹配字段的值,图中的示例是`192.168.236.75`。
+
+ 
+
* `host` 匹配
@@ -134,9 +166,114 @@ description: 选择器和规则管理
* 尤其是在 `waf` 插件里面,如果发现一个 `host` 地址有攻击,可以新增一条匹配条件,填上该 `host`,拒绝该 `host` 的访问。
- * 如果在 `Apache ShenYu` 前面使用了 `nginx` 代理,为了获取正确的 `host`,可以参考 [自定义解析IP与Host](../../developer/custom-parsing-ip-and-host)
+ * 如果在 `Apache ShenYu` 前面使用了 `nginx` 代理,为了获取正确的 `host`,可以参考 [自定义解析IP与Host](../../developer/custom-parsing-ip-and-host) 。
+
+ * 使用该匹配方式的时候,填写匹配字段的值,图中的示例是`localhost`。
+
+ 
* `post` 匹配
- * 不推荐使用。
+ * 从请求上下文(`org.apache.shenyu.plugin.api.context.ShenyuContext`)中获取条件参数,需要通过反射获取字段的值,不推荐使用此方式。
+
+ * 使用该匹配方式的时候,需要填写字段名称和字段值,图中的示例分别是`contextPath`和`/http`。
+
+ 
+
+
+* `cookie` 匹配
+
+ * 这个是根据 `http` 调用方的请求头中`Cookie`作为条件参数进行匹配。
+
+ * 使用该匹配方式的时候,需要填写字段名称和字段值,图中的示例分别是`shenyu`和`shenyu_cookie`。
+
+ 
+
+* `req_method` 匹配
+
+ * 这个是根据 `http` 调用方的请求形式来进行匹配,比如`GET`、`POST`等。
+
+ * 使用该匹配方式的时候,填写匹配字段的值,图中的示例是`GET`。
+
+ 
+
+如果想更深入理解条件参数的获取,请阅读相关源码,包名是`org.apache.shenyu.plugin.base.condition.data`:
+
+|匹配策略 | 源码类 |
+|:------------------------ |:----- |
+|`uri` 匹配 |`URIParameterData` |
+|`header` 匹配 |`HeaderParameterData` |
+|`query` 匹配 |`QueryParameterData` |
+|`ip`匹配 |`IpParameterData` |
+|`host`匹配 |`HostParameterData` |
+|`post` 匹配 |`PostParameterData` |
+|`cookie` 匹配 |`CookieParameterData` |
+|`req_method` 匹配 |`RequestMethodParameterData` |
+
+
+## 条件匹配策略
+
+通过条件参数能够获取到请求的真实数据。真实数据如何匹配上选择器或规则预设的条件数据,是通过条件匹配策略来实现。
+
+* `match` 匹配策略
+
+ `match` 的方式支持模糊匹配(`/**`)。假如你的选择器条件设置如下,那么请求 `/http/order/findById` 就可以匹配上。
+
+ 
+
+* `=` 匹配策略
+
+ `=` 的方式表示请求的真实数据和预设的条件数据相等。假如你的选择器条件设置如下:请求`uri`等于`/http/order/findById`,那么请求 `/http/order/findById?id=1` 就可以匹配上。
+
+ 
+
+* `regex` 匹配策略
+
+ `regex` 的方式表示请求的真实数据能够满足预设条件的正则表达式才能匹配成功。假如你的规则条件设置如下:请求参数中包含`id`,并且是3位数字。那么请求 `/http/order/findById?id=900` 就可以匹配上。
+
+ 
+
+* `contains` 匹配策略
+
+ `contains` 的方式表示请求的真实数据包含预设的条件数据。假如你的规则条件设置如下:请求`uri`中包含`findById`。那么请求 `/http/order/findById?id=1` 就可以匹配上。
+
+ 
+
+* `SpEL` 匹配策略
+
+ `SpEL` 的方式表示请求的真实数据能够满足预设的`SpEL`表达式。假如你的规则条件设置如下:请求参数中包含`id`,并且`id`大于`100`。那么请求 `/http/order/findById?id=101` 就可以匹配上。
+
+ 
+
+* `Groovy` 匹配策略
+
+ `Groovy` 的方式表示请求的真实数据能够满足预设的`Groovy`表达式。假如你的规则条件设置如下:请求参数中包含`id`,并且`id`等`100`。那么请求 `/http/order/findById?id=100` 就可以匹配上。
+
+ 
+
+* `TimeBefore` 匹配策略
+
+ `TimeBefore` 的方式表示请求时间在预设的条件时间之前才能匹配成功。假如你的规则条件设置如下:请求参数中包含`date`,并且`date`小于`2021-09-26 06:12:10`。那么请求 `/http/order/findById?id=100&date=2021-09-22 06:12:10` 就可以匹配上。
+
+ 
+
+* `TimeAfter` 匹配策略
+
+ `TimeAfter` 的方式表示请求时间在预设的条件时间之后才能匹配成功。假如你的规则条件设置如下:请求参数中包含`date`,并且`date`大于`2021-09-26 06:12:10`。那么请求 `/http/order/findById?id=100&date=2021-09-29 06:12:10` 就可以匹配上。
+
+ 
+
+如果想更深入理解条件匹配策略,请阅读相关源码,包名是`org.apache.shenyu.plugin.base.condition.judge`:
+
+|匹配策略 | 源码类 |
+|:------------------------ |:----- |
+|`match` 匹配策略 |`MatchPredicateJudge` |
+|`=` 匹配策略 |`EqualsPredicateJudge` |
+|`regex` 匹配策略 |`RegexPredicateJudge` |
+|`contains` 匹配策略 |`ContainsPredicateJudge` |
+|`SpEL` 匹配策略 |`SpELPredicateJudge` |
+|`Groovy` 匹配策略 |`GroovyPredicateJudge` |
+|`TimeBefore` 匹配策略 |`TimerBeforePredicateJudge` |
+|`TimeAfter` 匹配策略 |`TimerAfterPredicateJudge` |
+
diff --git a/static/img/shenyu/basicConfig/selectorRule/parameter-data-cookie-en.png b/static/img/shenyu/basicConfig/selectorRule/parameter-data-cookie-en.png
new file mode 100644
index 0000000..07145b8
Binary files /dev/null and b/static/img/shenyu/basicConfig/selectorRule/parameter-data-cookie-en.png differ
diff --git a/static/img/shenyu/basicConfig/selectorRule/parameter-data-cookie-zh.png b/static/img/shenyu/basicConfig/selectorRule/parameter-data-cookie-zh.png
new file mode 100644
index 0000000..08b0b93
Binary files /dev/null and b/static/img/shenyu/basicConfig/selectorRule/parameter-data-cookie-zh.png differ
diff --git a/static/img/shenyu/basicConfig/selectorRule/parameter-data-header-en.png b/static/img/shenyu/basicConfig/selectorRule/parameter-data-header-en.png
new file mode 100644
index 0000000..fa55a07
Binary files /dev/null and b/static/img/shenyu/basicConfig/selectorRule/parameter-data-header-en.png differ
diff --git a/static/img/shenyu/basicConfig/selectorRule/parameter-data-header-zh.png b/static/img/shenyu/basicConfig/selectorRule/parameter-data-header-zh.png
new file mode 100644
index 0000000..5cdffc1
Binary files /dev/null and b/static/img/shenyu/basicConfig/selectorRule/parameter-data-header-zh.png differ
diff --git a/static/img/shenyu/basicConfig/selectorRule/parameter-data-host-en.png b/static/img/shenyu/basicConfig/selectorRule/parameter-data-host-en.png
new file mode 100644
index 0000000..0e976b4
Binary files /dev/null and b/static/img/shenyu/basicConfig/selectorRule/parameter-data-host-en.png differ
diff --git a/static/img/shenyu/basicConfig/selectorRule/parameter-data-host-zh.png b/static/img/shenyu/basicConfig/selectorRule/parameter-data-host-zh.png
new file mode 100644
index 0000000..c1eeb21
Binary files /dev/null and b/static/img/shenyu/basicConfig/selectorRule/parameter-data-host-zh.png differ
diff --git a/static/img/shenyu/basicConfig/selectorRule/parameter-data-ip-en.png b/static/img/shenyu/basicConfig/selectorRule/parameter-data-ip-en.png
new file mode 100644
index 0000000..7d1bf59
Binary files /dev/null and b/static/img/shenyu/basicConfig/selectorRule/parameter-data-ip-en.png differ
diff --git a/static/img/shenyu/basicConfig/selectorRule/parameter-data-ip-zh.png b/static/img/shenyu/basicConfig/selectorRule/parameter-data-ip-zh.png
new file mode 100644
index 0000000..88418f0
Binary files /dev/null and b/static/img/shenyu/basicConfig/selectorRule/parameter-data-ip-zh.png differ
diff --git a/static/img/shenyu/basicConfig/selectorRule/parameter-data-post-en.png b/static/img/shenyu/basicConfig/selectorRule/parameter-data-post-en.png
new file mode 100644
index 0000000..c9103b9
Binary files /dev/null and b/static/img/shenyu/basicConfig/selectorRule/parameter-data-post-en.png differ
diff --git a/static/img/shenyu/basicConfig/selectorRule/parameter-data-post-zh.png b/static/img/shenyu/basicConfig/selectorRule/parameter-data-post-zh.png
new file mode 100644
index 0000000..2a4aa75
Binary files /dev/null and b/static/img/shenyu/basicConfig/selectorRule/parameter-data-post-zh.png differ
diff --git a/static/img/shenyu/basicConfig/selectorRule/parameter-data-query-en.png b/static/img/shenyu/basicConfig/selectorRule/parameter-data-query-en.png
new file mode 100644
index 0000000..2e9164d
Binary files /dev/null and b/static/img/shenyu/basicConfig/selectorRule/parameter-data-query-en.png differ
diff --git a/static/img/shenyu/basicConfig/selectorRule/parameter-data-query-zh.png b/static/img/shenyu/basicConfig/selectorRule/parameter-data-query-zh.png
new file mode 100644
index 0000000..b14d046
Binary files /dev/null and b/static/img/shenyu/basicConfig/selectorRule/parameter-data-query-zh.png differ
diff --git a/static/img/shenyu/basicConfig/selectorRule/parameter-data-req_method-en.png b/static/img/shenyu/basicConfig/selectorRule/parameter-data-req_method-en.png
new file mode 100644
index 0000000..e0bfab8
Binary files /dev/null and b/static/img/shenyu/basicConfig/selectorRule/parameter-data-req_method-en.png differ
diff --git a/static/img/shenyu/basicConfig/selectorRule/parameter-data-req_method-zh.png b/static/img/shenyu/basicConfig/selectorRule/parameter-data-req_method-zh.png
new file mode 100644
index 0000000..adc3a28
Binary files /dev/null and b/static/img/shenyu/basicConfig/selectorRule/parameter-data-req_method-zh.png differ
diff --git a/static/img/shenyu/basicConfig/selectorRule/parameter-data-uri-en.png b/static/img/shenyu/basicConfig/selectorRule/parameter-data-uri-en.png
new file mode 100644
index 0000000..7b86f90
Binary files /dev/null and b/static/img/shenyu/basicConfig/selectorRule/parameter-data-uri-en.png differ
diff --git a/static/img/shenyu/basicConfig/selectorRule/parameter-data-uri-zh.png b/static/img/shenyu/basicConfig/selectorRule/parameter-data-uri-zh.png
new file mode 100644
index 0000000..73320d9
Binary files /dev/null and b/static/img/shenyu/basicConfig/selectorRule/parameter-data-uri-zh.png differ
diff --git a/static/img/shenyu/basicConfig/selectorRule/predicate-judge-contains-en.png b/static/img/shenyu/basicConfig/selectorRule/predicate-judge-contains-en.png
new file mode 100644
index 0000000..03fb802
Binary files /dev/null and b/static/img/shenyu/basicConfig/selectorRule/predicate-judge-contains-en.png differ
diff --git a/static/img/shenyu/basicConfig/selectorRule/predicate-judge-contains-zh.png b/static/img/shenyu/basicConfig/selectorRule/predicate-judge-contains-zh.png
new file mode 100644
index 0000000..3d731a0
Binary files /dev/null and b/static/img/shenyu/basicConfig/selectorRule/predicate-judge-contains-zh.png differ
diff --git a/static/img/shenyu/basicConfig/selectorRule/predicate-judge-equals-en.png b/static/img/shenyu/basicConfig/selectorRule/predicate-judge-equals-en.png
new file mode 100644
index 0000000..2c767a8
Binary files /dev/null and b/static/img/shenyu/basicConfig/selectorRule/predicate-judge-equals-en.png differ
diff --git a/static/img/shenyu/basicConfig/selectorRule/predicate-judge-equals-zh.png b/static/img/shenyu/basicConfig/selectorRule/predicate-judge-equals-zh.png
new file mode 100644
index 0000000..423b25a
Binary files /dev/null and b/static/img/shenyu/basicConfig/selectorRule/predicate-judge-equals-zh.png differ
diff --git a/static/img/shenyu/basicConfig/selectorRule/predicate-judge-groovy-en.png b/static/img/shenyu/basicConfig/selectorRule/predicate-judge-groovy-en.png
new file mode 100644
index 0000000..08842e9
Binary files /dev/null and b/static/img/shenyu/basicConfig/selectorRule/predicate-judge-groovy-en.png differ
diff --git a/static/img/shenyu/basicConfig/selectorRule/predicate-judge-groovy-zh.png b/static/img/shenyu/basicConfig/selectorRule/predicate-judge-groovy-zh.png
new file mode 100644
index 0000000..73ea984
Binary files /dev/null and b/static/img/shenyu/basicConfig/selectorRule/predicate-judge-groovy-zh.png differ
diff --git a/static/img/shenyu/basicConfig/selectorRule/predicate-judge-match-en.png b/static/img/shenyu/basicConfig/selectorRule/predicate-judge-match-en.png
new file mode 100644
index 0000000..24ee41a
Binary files /dev/null and b/static/img/shenyu/basicConfig/selectorRule/predicate-judge-match-en.png differ
diff --git a/static/img/shenyu/basicConfig/selectorRule/predicate-judge-match-zh.png b/static/img/shenyu/basicConfig/selectorRule/predicate-judge-match-zh.png
new file mode 100644
index 0000000..6bfcf8a
Binary files /dev/null and b/static/img/shenyu/basicConfig/selectorRule/predicate-judge-match-zh.png differ
diff --git a/static/img/shenyu/basicConfig/selectorRule/predicate-judge-regex-en.png b/static/img/shenyu/basicConfig/selectorRule/predicate-judge-regex-en.png
new file mode 100644
index 0000000..3fdb20e
Binary files /dev/null and b/static/img/shenyu/basicConfig/selectorRule/predicate-judge-regex-en.png differ
diff --git a/static/img/shenyu/basicConfig/selectorRule/predicate-judge-regex-zh.png b/static/img/shenyu/basicConfig/selectorRule/predicate-judge-regex-zh.png
new file mode 100644
index 0000000..287002f
Binary files /dev/null and b/static/img/shenyu/basicConfig/selectorRule/predicate-judge-regex-zh.png differ
diff --git a/static/img/shenyu/basicConfig/selectorRule/predicate-judge-spel-en.png b/static/img/shenyu/basicConfig/selectorRule/predicate-judge-spel-en.png
new file mode 100644
index 0000000..69d1cb4
Binary files /dev/null and b/static/img/shenyu/basicConfig/selectorRule/predicate-judge-spel-en.png differ
diff --git a/static/img/shenyu/basicConfig/selectorRule/predicate-judge-spel-zh.png b/static/img/shenyu/basicConfig/selectorRule/predicate-judge-spel-zh.png
new file mode 100644
index 0000000..c4faa6b
Binary files /dev/null and b/static/img/shenyu/basicConfig/selectorRule/predicate-judge-spel-zh.png differ
diff --git a/static/img/shenyu/basicConfig/selectorRule/predicate-judge-timeafter-en.png b/static/img/shenyu/basicConfig/selectorRule/predicate-judge-timeafter-en.png
new file mode 100644
index 0000000..fbd46fc
Binary files /dev/null and b/static/img/shenyu/basicConfig/selectorRule/predicate-judge-timeafter-en.png differ
diff --git a/static/img/shenyu/basicConfig/selectorRule/predicate-judge-timeafter-zh.png b/static/img/shenyu/basicConfig/selectorRule/predicate-judge-timeafter-zh.png
new file mode 100644
index 0000000..00fae18
Binary files /dev/null and b/static/img/shenyu/basicConfig/selectorRule/predicate-judge-timeafter-zh.png differ
diff --git a/static/img/shenyu/basicConfig/selectorRule/predicate-judge-timebefore-en.png b/static/img/shenyu/basicConfig/selectorRule/predicate-judge-timebefore-en.png
new file mode 100644
index 0000000..2d92866
Binary files /dev/null and b/static/img/shenyu/basicConfig/selectorRule/predicate-judge-timebefore-en.png differ
diff --git a/static/img/shenyu/basicConfig/selectorRule/predicate-judge-timebefore-zh.png b/static/img/shenyu/basicConfig/selectorRule/predicate-judge-timebefore-zh.png
new file mode 100644
index 0000000..5fc41ca
Binary files /dev/null and b/static/img/shenyu/basicConfig/selectorRule/predicate-judge-timebefore-zh.png differ