SylviaBABY commented on code in PR #7609:
URL: https://github.com/apache/apisix/pull/7609#discussion_r937461901


##########
docs/zh/latest/terminology/plugin.md:
##########
@@ -82,33 +94,9 @@ local _M = {
 }
 ```
 
-上面的配置意味着将 jwt-auth 插件的错误响应自定义为 '{"message": "Missing credential in request"}'。
-
-```
-{
-    "jwt-auth": {
-        "_meta": {
-            "filter": {
-                {"arg_version", "==", "v2"}
-            }
-        }
-    }
-}
-```
-
-这个配置示例意味着只有在请求参数中 `version` 等于 `v2` 时 `jwt-auth` 插件才会执行。
-
-### 在 `_meta` 下的插件通用配置
-
-| 名称         | 类型 | 描述           |
-|--------------|------|----------------|
-| error_response | string/object  | 自定义错误响应 |
-| priority       | integer        | 自定义插件优先级 |
-| filter  | array   | 根据请求的参数,在运行时控制插件是否执行。由一个或多个{var, operator, 
val}元素组成列表,类似这样:{{var, operator, val}, {var, operator, val}, 
...}}。例如:`{"arg_name", "==", "json"}`,表示当前请求参数 name 是 json。这里的 var 与 Nginx 
内部自身变量命名是保持一致。操作符的具体用法请看[lua-resty-expr](https://github.com/api7/lua-resty-expr#operator-list)
 的 operator-list 部分。|
-
 ### 自定义插件优先级
 
-所有插件都有默认优先级,但是可以自定义插件优先级来改变插件执行顺序。
+所有插件都有默认优先级,但是通过 `priority` 配置项可以自定义插件优先级从而改变插件执行顺序。

Review Comment:
   ```suggestion
   所有插件都有默认优先级,但你仍可以通过 `priority` 配置项来自定义插件优先级,从而改变插件执行顺序。
   ```



##########
docs/en/latest/terminology/plugin.md:
##########
@@ -76,7 +76,19 @@ ip-restriction exits with http status code 403
 
 ## Plugin common configuration
 
-Some common configurations can be applied to the plugin configuration. For 
example,
+Some common configurations can be applied to plugins through the `_meta` 
configuration items, the specific configuration items are as follows:
+
+| Name         | Type | Description |
+|--------------|------|-------------|
+| error_response | string/object  | Custom error response |
+| priority       | integer        | Custom plugin priority |
+| filter  | array | Depending on the requested parameters, it is decided at 
runtime whether the plugin should be executed. Something like this: {{var, 
operator, val}, {var, operator, val}, ...}}. For example: `{"arg_version", 
"==", "v2"}`, indicating that the current request parameter `version` is `v2`. 
The variables here are consistent with Nginx internal variables. For details on 
supported operators, please see 
[lua-resty-expr](https://github.com/api7/lua-resty-expr#operator-list). |
+
+### custom error response

Review Comment:
   ```suggestion
   ### Custom error response
   ```



##########
docs/zh/latest/terminology/plugin.md:
##########
@@ -142,6 +130,116 @@ serverless-pre-function 的默认优先级是 
10000,serverless-post-function 
 - 自定义插件优先级只会影响插件实例绑定的主体,不会影响该插件的所有实例。比如上面的插件配置属于路由 A ,路由 B 上的插件 
serverless-post-function 和 serverless-post-function 插件执行顺序不会受到影响,会使用默认优先级。
 - 自定义插件优先级不适用于 consumer 上配置的插件的 rewrite 阶段。路由上配置的插件的 rewrite 阶段将会优先运行,然后才会运行 
consumer 上除 auth 插件之外的其他插件的 rewrite 阶段。
 
+### 动态控制插件是否执行
+
+默认情况下,在路由中指定的插件都会被执行。但是我们可以通过 `filter` 配置项为插件添加一个过滤器,通过过滤器的执行结果控制插件是否执行。
+
+下面的配置意味着只有当请求查询参数中 `version` 值为 `v2` 时, `proxy-rewrite` 插件才会执行。
+
+```json
+{
+    "proxy-rewrite": {
+        "_meta": {
+            "filter": [
+                ["arg_version", "==", "v2"]
+            ]
+        },
+        "uri": "/anything"
+    }
+}
+```
+
+使用上述配置创建一条完整的路由:

Review Comment:
   ```suggestion
   使用下述配置创建一条完整的路由:
   ```



##########
docs/zh/latest/terminology/plugin.md:
##########
@@ -142,6 +130,116 @@ serverless-pre-function 的默认优先级是 
10000,serverless-post-function 
 - 自定义插件优先级只会影响插件实例绑定的主体,不会影响该插件的所有实例。比如上面的插件配置属于路由 A ,路由 B 上的插件 
serverless-post-function 和 serverless-post-function 插件执行顺序不会受到影响,会使用默认优先级。
 - 自定义插件优先级不适用于 consumer 上配置的插件的 rewrite 阶段。路由上配置的插件的 rewrite 阶段将会优先运行,然后才会运行 
consumer 上除 auth 插件之外的其他插件的 rewrite 阶段。
 
+### 动态控制插件是否执行
+
+默认情况下,在路由中指定的插件都会被执行。但是我们可以通过 `filter` 配置项为插件添加一个过滤器,通过过滤器的执行结果控制插件是否执行。
+
+下面的配置意味着只有当请求查询参数中 `version` 值为 `v2` 时, `proxy-rewrite` 插件才会执行。

Review Comment:
   ```suggestion
   下述配置表示,只有当请求查询参数中 `version` 值为 `v2` 时, `proxy-rewrite` 插件才会执行。
   ```



##########
docs/zh/latest/terminology/plugin.md:
##########
@@ -68,7 +68,19 @@ local _M = {
 
 ## 插件通用配置
 
-一些通用的配置可以应用于插件配置。比如说。
+通过 `_meta` 配置项可以将一些通用的配置应用于插件,具体配置项如下:
+
+| 名称         | 类型 | 描述           |
+|--------------|------|----------------|
+| error_response | string/object  | 自定义错误响应 |
+| priority       | integer        | 自定义插件优先级 |
+| filter  | array   | 根据请求的参数,在运行时控制插件是否执行。由一个或多个{var, operator, 
val}元素组成列表,类似这样:{{var, operator, val}, {var, operator, val}, 
...}}。例如:`{"arg_version", "==", "v2"}`,表示当前请求参数 `version` 是 `v2`。这里的 var 与 
Nginx 
内部自身变量命名是保持一致。操作符的具体用法请看[lua-resty-expr](https://github.com/api7/lua-resty-expr#operator-list)
 的 operator-list 部分。|
+
+### 自定义错误响应
+
+通过 `error_response` 配置,可以将任意插件的错误响应配置成一个固定的值,避免因为插件内置的错误响应信息而带来困扰。
+
+下面的配置意味着将 `jwt-auth` 插件的错误响应自定义为 '{"message": "Missing credential in 
request"}'。

Review Comment:
   ```suggestion
   如下配置表示将 `jwt-auth` 插件的错误响应自定义为 '{"message": "Missing credential in 
request"}'。
   ```



##########
docs/en/latest/terminology/plugin.md:
##########
@@ -76,7 +76,19 @@ ip-restriction exits with http status code 403
 
 ## Plugin common configuration
 
-Some common configurations can be applied to the plugin configuration. For 
example,
+Some common configurations can be applied to plugins through the `_meta` 
configuration items, the specific configuration items are as follows:
+
+| Name         | Type | Description |
+|--------------|------|-------------|
+| error_response | string/object  | Custom error response |
+| priority       | integer        | Custom plugin priority |
+| filter  | array | Depending on the requested parameters, it is decided at 
runtime whether the plugin should be executed. Something like this: {{var, 
operator, val}, {var, operator, val}, ...}}. For example: `{"arg_version", 
"==", "v2"}`, indicating that the current request parameter `version` is `v2`. 
The variables here are consistent with Nginx internal variables. For details on 
supported operators, please see 
[lua-resty-expr](https://github.com/api7/lua-resty-expr#operator-list). |

Review Comment:
   ```suggestion
   | filter  | array | Depending on the requested parameters, it is decided at 
runtime whether the plugin should be executed. Something like this: {{var, 
operator, val}, {var, operator, val}, ...}}. For example: `{"arg_version", 
"==", "v2"}`, indicating that the current request parameter `version` is `v2`. 
The variables here are consistent with NGINX internal variables. For details on 
supported operators, please see 
[lua-resty-expr](https://github.com/api7/lua-resty-expr#operator-list). |
   ```



##########
docs/zh/latest/terminology/plugin.md:
##########
@@ -68,7 +68,19 @@ local _M = {
 
 ## 插件通用配置
 
-一些通用的配置可以应用于插件配置。比如说。
+通过 `_meta` 配置项可以将一些通用的配置应用于插件,具体配置项如下:
+
+| 名称         | 类型 | 描述           |
+|--------------|------|----------------|
+| error_response | string/object  | 自定义错误响应 |
+| priority       | integer        | 自定义插件优先级 |
+| filter  | array   | 根据请求的参数,在运行时控制插件是否执行。由一个或多个{var, operator, 
val}元素组成列表,类似这样:{{var, operator, val}, {var, operator, val}, 
...}}。例如:`{"arg_version", "==", "v2"}`,表示当前请求参数 `version` 是 `v2`。这里的 var 与 
Nginx 
内部自身变量命名是保持一致。操作符的具体用法请看[lua-resty-expr](https://github.com/api7/lua-resty-expr#operator-list)
 的 operator-list 部分。|

Review Comment:
   ```suggestion
   | filter  | array   | 根据请求的参数,在运行时控制插件是否执行。此配置由一个或多个 {var, operator, val} 
元素组成列表,类似 {{var, operator, val}, {var, operator, val}, ...}}。例如 
`{"arg_version", "==", "v2"}`,表示当前请求参数 `version` 是 `v2`。这里的 var 与 NGINX 
内部自身变量命名是保持一致。操作符的具体用法请看[lua-resty-expr](https://github.com/api7/lua-resty-expr#operator-list)
 的 operator-list 部分。|
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to