This is an automated email from the ASF dual-hosted git repository.

wenming pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-apisix.git


The following commit(s) were added to refs/heads/master by this push:
     new c8a00b1  doc: add usage about global ruls (#1211)
c8a00b1 is described below

commit c8a00b1152d3a1466346e37fdbe7bec68be48f13
Author: Vinci Xu <277040...@qq.com>
AuthorDate: Sat Mar 7 19:52:55 2020 +0800

    doc: add usage about global ruls (#1211)
---
 README.md                     |  2 +-
 README_CN.md                  |  2 +-
 doc/architecture-design-cn.md | 29 +++++++++++++++++++++++++++++
 doc/architecture-design.md    | 29 +++++++++++++++++++++++++++++
 4 files changed, 60 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index a84b637..fb64b54 100644
--- a/README.md
+++ b/README.md
@@ -99,7 +99,7 @@ A/B testing, canary release, blue-green deployment, limit 
rate, defense against
     - Version Control: Supports rollbacks of operations.
     - CLI: start\stop\reload APISIX through the command line.
     - [Stand-alone mode](doc/stand-alone.md): Supports to load route rules 
from local yaml file, it is more friendly such as under the kubernetes(k8s).
-    - Global Rule: Allows to run any plugin for all request, eg: limit rate, 
IP filter etc.
+    - [Global Rule](doc/architecture-design.md#Global-Rule): Allows to run any 
plugin for all request, eg: limit rate, IP filter etc.
     - High performance: The single-core QPS reaches 18k with an average delay 
of less than 0.2 milliseconds.
     - [Fault Injection](doc/plugins/fault-injection.md)
     - [REST Admin API](doc/admin-api.md)
diff --git a/README_CN.md b/README_CN.md
index ab7290c..10c658a 100644
--- a/README_CN.md
+++ b/README_CN.md
@@ -99,7 +99,7 @@ A/B 测试、金丝雀发布(灰度发布)、蓝绿部署、限流限速、抵
     - 版本控制:支持操作的多次回滚。
     - CLI: 使用命令行来启动、关闭和重启 APISIX。
     - [单机模式](doc/stand-alone-cn.md): 支持从本地配置文件中加载路由规则,在 kubernetes(k8s) 
等环境下更友好。
-    - 全局规则:允许对所有请求执行插件,比如黑白名单、限流限速等。
+    - 
[全局规则](doc/architecture-design-cn.md#Global-Rule):允许对所有请求执行插件,比如黑白名单、限流限速等。
     - 高性能:在单核上 QPS 可以达到 18k,同时延迟只有 0.2 毫秒。
     - [故障注入](doc/plugins/fault-injection-cn.md)
     - [REST Admin API](doc/admin-api-cn.md)
diff --git a/doc/architecture-design-cn.md b/doc/architecture-design-cn.md
index 0747151..b212b0f 100644
--- a/doc/architecture-design-cn.md
+++ b/doc/architecture-design-cn.md
@@ -26,6 +26,7 @@
 - [**Upstream**](#upstream)
 - [**Router**](#router)
 - [**Consumer**](#consumer)
+- [**Global Rule**](#Global-Rule)
 - [**Debug mode**](#Debug-mode)
 
 ## APISIX
@@ -529,6 +530,34 @@ HTTP/1.1 503 Service Temporarily Unavailable
 
 [返回目录](#目录)
 
+## Global Rule
+[Plugin](#Plugin) 只能绑定在 [Service](#Service) 或者 [Route](#Route) 
上,如果我们需要一个能作用于所有请求的 [Plugin](#Plugin) 该怎么办呢?
+这时候我们可以使用 `GlobalRule` 来注册一个全局的 [Plugin](#Plugin):
+```shell
+curl -X PUT \
+  https://{apisix_listen_address}/apisix/admin/global_rules/1 \
+  -H 'Content-Type: application/json' \
+  -d '{
+        "plugins": {
+            "limit-count": {
+                "time_window": 60,
+                "policy": "local",
+                "count": 2,
+                "key": "remote_addr",
+                "rejected_code": 503
+            }
+        }
+    }'
+```
+如上所注册的 `limit-count` 插件将会作用于所有的请求。
+
+我们可以通过以下接口查看所有的 `GlobalRule`:
+```shell
+curl https://{apisix_listen_address}/apisix/admin/global_rules
+```
+
+[返回目录](#目录)
+
 ## Debug mode
 
 ### 基本调试模式
diff --git a/doc/architecture-design.md b/doc/architecture-design.md
index 3a312f7..d5e7645 100644
--- a/doc/architecture-design.md
+++ b/doc/architecture-design.md
@@ -28,6 +28,7 @@
 - [**Upstream**](#upstream)
 - [**Router**](#router)
 - [**Consumer**](#consumer)
+- [**Global Rule**](#Global-Rule)
 - [**Debug mode**](#Debug-mode)
 
 ## APISIX
@@ -518,6 +519,34 @@ HTTP/1.1 503 Service Temporarily Unavailable
 
 [Back to top](#Table-of-contents)
 
+## Global Rule
+[Plugin](#Plugin) just can be binded to [Service](#Service) or 
[Route](#Route), if we want a [Plugin](#Plugin) work on all requests, how to do 
it?
+We can register a global [Plugin](#Plugin) with `GlobalRule`:
+```shell
+curl -X PUT \
+  https://{apisix_listen_address}/apisix/admin/global_rules/1 \
+  -H 'Content-Type: application/json' \
+  -d '{
+        "plugins": {
+            "limit-count": {
+                "time_window": 60,
+                "policy": "local",
+                "count": 2,
+                "key": "remote_addr",
+                "rejected_code": 503
+            }
+        }
+    }'
+```
+Now, the `limit-count` plugin will work on all requets
+
+we can list all `GlobalRule` via admin api as below:
+```shell
+curl https://{apisix_listen_address}/apisix/admin/global_rules
+```
+
+[Back to top](#Table-of-contents)
+
 ## Debug mode
 
 ### Basic Debug Mode

Reply via email to