Skip to content

Commit 4f4b885

Browse files
committed
There are some lint errors
1 parent b7e0ac0 commit 4f4b885

File tree

1 file changed

+0
-7
lines changed

1 file changed

+0
-7
lines changed

docs/zh/latest/tutorials/manage-api-consumers.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ API 消费者是指使用某个 API 的用户,但他们并不会专门为该 A
6767
在本示例中,我们将使用一个基于 [ASP.NET Core Web API](https://learn.microsoft.com/en-us/aspnet/core/?view=aspnetcore-7.0)[示例项目](https://github.com/Boburmirzo/apisix-api-consumers-management),该项目包含一个简单的 `GET` 接口,用于获取商品列表。
6868
项目的运行方式可在其 [README 文件](https://github.com/Boburmirzo/apisix-api-consumers-management#readme) 中找到详细说明。
6969

70-
7170
### 为单个消费者启用限流(Rate Limiting)
7271

7372
假设此时示例项目已经启动运行。
@@ -80,7 +79,6 @@ API 消费者是指使用某个 API 的用户,但他们并不会专门为该 A
8079

8180
以上步骤只需通过两条 [curl 命令](https://en.wikipedia.org/wiki/CURL) 调用 APISIX 的 [Admin API](https://apisix.apache.org/zh/docs/apisix/admin-api/) 即可完成。
8281

83-
8482
第一条命令创建一个启用了 API Key 认证的 **新消费者**,并配置限流规则:
8583
该消费者在 60 秒内最多只能调用产品 API 两次。
8684

@@ -103,7 +101,6 @@ curl http://127.0.0.1:9180/apisix/admin/consumers -H "X-API-KEY: $admin_key" -X
103101
}'
104102
```
105103

106-
107104
接下来,我们定义一个新的 **Route(路由)****Upstream(上游)**
108105
使得所有到达网关端点 `/api/products` 的请求在通过认证后,都会被转发到示例项目的产品服务。
109106

@@ -148,7 +145,6 @@ Server: APISIX/2.13.1
148145

149146
当请求次数达到阈值后,APISIX 将拒绝后续请求。
150147

151-
152148
### 为消费者组启用限流(Rate Limiting for Consumer Groups)
153149

154150
在 Apache APISIX 中,[Consumer Group(消费者组)](https://apisix.apache.org/zh/docs/apisix/terminology/consumer-group/) 对象用于管理开发者对后端服务的可见性。
@@ -210,7 +206,6 @@ curl http://127.0.0.1:9180/apisix/admin/consumer_groups/premium_plan -H "X-API-K
210206
在上述步骤中,我们为 **Basic Plan** 设置了限流规则:每 60 秒内仅允许 **2 次请求**
211207
**Premium Plan** 则允许在相同时间窗口内执行 **200 次 API 请求**
212208

213-
214209
**创建并将第一个消费者加入 Basic 组**
215210

216211
```shell
@@ -256,7 +251,6 @@ curl http://127.0.0.1:9180/apisix/admin/consumers -H "X-API-KEY: $admin_key" -X
256251
}'
257252
```
258253

259-
260254
之后,我们可以验证限流效果:
261255
属于 **Basic Plan** 组的第一个消费者 `consumer1` 在 1 分钟内调用 API 超过 2 次后,将收到 **403 HTTP 状态码错误**
262256
而属于 **Premium Plan** 组的其他两个消费者则可继续请求,直到达到各自的请求上限。
@@ -277,7 +271,6 @@ curl -i http://127.0.0.1:9080/api/products -H 'apikey: auth-three'
277271

278272
请注意,你还可以在任意时刻将消费者添加到或移出消费者组,并启用其他内置插件。
279273

280-
281274
## 更多教程
282275

283276
阅读我们的其他 [教程](./expose-api.md),以了解更多有关 **API 管理(API Management)** 的内容。

0 commit comments

Comments
 (0)