Skip to content

Commit 1894f66

Browse files
committed
Signed-off-by: yutao04 <[email protected]>
docs: add response-header-rewrite and static-downgrade plugin docs
1 parent aaa1a4c commit 1894f66

File tree

5 files changed

+170
-7
lines changed

5 files changed

+170
-7
lines changed

docs/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
## 插件
44

55
* [插件界面配置引导](plugin/plugin-configuring-guide.md)
6-
76
* [percent-limit](plugin/percent-limit.md)
7+
* [static-downgrade](plugin/static-downgrade.md)
8+
* [response-header-rewrite](plugin/response-header-rewrite.md)
9+
* [ua-restriction](plugin/ua-restriction.md)
810

911
## 问题定位
1012

11-
* [问题定位引导](troubleshooting/troubleshooting.md)
12-
13+
* [问题定位引导](troubleshooting/troubleshooting.md)

docs/plugin/percent-limit.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@
66

77
## 属性
88

9-
| 名称 | 类型 | 必选项 | 默认值 | 描述 |
10-
|-------|--------|-----|-----|------------|
11-
| 限流百分比 | number || - | 允许通过流量的百分比 |
9+
| 名称 | 类型 | 必选项 | 范围 | 描述 |
10+
|---------------|---------|-----|---------------|------------|
11+
| kind | string || percent-limit | 插件类型(值固定) |
12+
| limit_percent | integer || [0, 100] | 允许通过流量的百分比 |
1213

1314

1415
## 前置条件
1516

16-
以下curl命令中存在变量,使用前需要替换为真实环境数据,变量以`{{}}`符号包裹,例如`{{ 网关ID }}`需要根据网关的实际ID进行替换
17+
以下curl命令中存在变量,使用前需要替换为真实环境数据,变量以`{{}}`符号包裹,例如`{{ 网关ID }}`需要根据网关的实际ID进行替换;创建插件命令中`PluginConfiguration`(插件配置)需要根据实际需要进行配置
1718

1819
## 创建
1920

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# 响应头部重写
2+
3+
## 描述
4+
5+
`response-header-rewrite`插件对请求的响应头进行变更,包括新增、删除和修改操作
6+
7+
## 属性
8+
9+
| 名称 | 类型 | 必选项 | 默认值 | 范围 | 描述 |
10+
|----------------------|--------|-----|--------|------------------------------|--------------|
11+
| header[].headerKey | string || - | length <= 200 | 需要操作的响应头名称 |
12+
| header[].operation | string || create | create<br/>update<br/>delete | 对响应的的操作类型 |
13+
| header[].headerValue | string || - | length <= 200 | 对于响应头新增或修改的值 |
14+
15+
16+
## 前置条件
17+
18+
以下curl命令中存在变量,使用前需要替换为真实环境数据,变量以`{{}}`符号包裹,例如`{{ 网关ID }}`需要根据网关的实际ID进行替换;创建插件命令中`PluginConfiguration`(插件配置)需要根据实际需要进行配置
19+
20+
## 创建
21+
22+
```shell
23+
curl -XPOST -v -H "Content-Type:application/json" -d '{
24+
"BindingObjectId": {{ 路由ID }},
25+
"BindingObjectType": "routeRule",
26+
"GwId": {{ 网关ID }},
27+
"PluginConfiguration": "{\"header\":[\"headerKey\": \"testHeader\",\"operation\": \"update\",\"headerValue\": \"testHeaderValue\"]}",
28+
"PluginType": "response-header-rewrite"
29+
}' http://{{ hango-portal ip:port }}/gdashboard?Action=BindingPlugin&Version=2019-09-01
30+
```
31+
32+
## 测试
33+
34+
```shell
35+
## 基于如下基础curl命令,根据后端服务要求将请求具体化,观察响应中的头变化是否符合插件配置的预期(响应头是否新增、被修改或删除)
36+
curl -v "http://{{ 网关IP }}/{{ 路由path }}" -H "host:{{ 网关关联域名 }}"
37+
```
38+
39+
## 删除
40+
41+
```shell
42+
curl -v -H "Content-Type:application/json" http://{{ hango-portal ip:port }}/gdashboard?PluginBindingInfoId={{ 插件ID }}&Action=UnbindingPlugin&Version=2019-09-01
43+
```
44+
45+
## 界面配置方法
46+
47+
[插件界面配置方法引导](plugin-configuring-guide.md)

docs/plugin/static-downgrade.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# 静态降级
2+
3+
## 描述
4+
5+
`static-downgrade`插件可匹配指定的请求进行降级,返回指定的响应内容
6+
7+
## 属性
8+
9+
| 名称 | 类型 | 必选项 | 范围 | 描述 |
10+
|-----------------------------------------|----------|-----|--------------------------------------------------------------------------------------|--------------|
11+
| kind | string || static-downgrade | 插件类型(值固定) |
12+
| condition.request.requestSwitch | boolean || - | 是否使用请求进行匹配 |
13+
| condition.request.method | []string || GET<br/>POST<br/>PUT<br/>DELETE<br/>OPTIONS<br/>HEAD<br/>TRACE<br/>CONNECT<br/>PATCH | HTTP的请求方法类型 |
14+
| condition.request.path.match_type | string || exact_match<br/>safe_regex_match | 请求路径匹配方式 |
15+
| condition.request.path.value | string || - | 请求路径匹配内容 |
16+
| condition.request.host.match_type | string || exact_match<br/>safe_regex_match | 请求域名匹配方式 |
17+
| condition.request.host.value | string || - | 请求域名匹配内容 |
18+
| condition.request.headers[].headerKey | string || - | 请求头匹配名称 |
19+
| condition.request.headers[].match_type | string || exact_match<br/>safe_regex_match | 请求头匹配匹配方式 |
20+
| condition.request.headers[].value | string || - | 请求头匹配匹配内容 |
21+
| condition.response.code.match_type | string || exact_match<br/>safe_regex_match | 响应状态码匹配方式 |
22+
| condition.response.code.value | integer || [200, 599] | 响应状态码匹配内容 |
23+
| condition.response.headers[].headerKey | string || - | 响应头匹配名称 |
24+
| condition.response.headers[].match_type | string || exact_match<br/>safe_regex_match | 响应头匹配方式 |
25+
| condition.response.headers[].value | string || - | 响应头匹配内容 |
26+
| response.code | integer || [200, 599] | 降级后返回的状态码 |
27+
| response.headers[key] | string || - | 降级后返回的响应头 |
28+
| response.headers[value] | string || - | 降级后返回的响应头对应值 |
29+
| response.body | string || - | 降级后返回的body内容 |
30+
31+
32+
## 前置条件
33+
34+
以下curl命令中存在变量,使用前需要替换为真实环境数据,变量以`{{}}`符号包裹,例如`{{ 网关ID }}`需要根据网关的实际ID进行替换;创建插件命令中`PluginConfiguration`(插件配置)需要根据实际需要进行配置
35+
36+
## 创建
37+
38+
```shell
39+
curl -XPOST -v -H "Content-Type:application/json" -d '{
40+
"BindingObjectId": {{ 路由ID }},
41+
"BindingObjectType": "routeRule",
42+
"GwId": {{ 网关ID }},
43+
"PluginConfiguration": "{\"condition\":{\"request\":{\"requestSwitch\":true,\"method\":[\"GET\",\"POST\"],\"path\":{\"match_type\":\"exact_match\",\"value\":\"/rootpath/subpath\"},\"headers\":[{\"headerKey\":\"reqHeader\",\"match_type\":\"exact_match\",\"value\":\"reqHeaderValue\"}]},\"response\":{\"code\":{\"match_type\":\"safe_regex_match\",\"value\":\"503\"},\"headers\":[{\"headerKey\":\"rspHeader\",\"match_type\":\"exact_match\",\"value\":\"rspHeaderValue\"}]}},\"kind\":\"static-downgrade\",\"response\":{\"headers\":{\"downgradeHeader\":\"downgradeHeaderValue\"},\"code\":\"200\",\"body\":\"Test Response Context\"}}",
44+
"PluginType": "static-downgrade"
45+
}' http://{{ hango-portal ip:port }}/gdashboard?Action=BindingPlugin&Version=2019-09-01
46+
```
47+
48+
## 测试
49+
50+
```shell
51+
## 基于如下基本的curl命令,添加插件中配置的请求头、响应头等降级条件,测试是否返回配置的响应内容(响应码、响应头和响应体)
52+
curl -v "http://{{ 网关IP }}/{{ 路由path }}" -H "host:{{ 网关关联域名 }}"
53+
54+
## 例如,插件中配置了降级条件配置了一个响应头为"reqHeader: reqHeaderValue",则需要构造如下请求进行测试
55+
curl -v "http://{{ 网关IP }}/{{ 路由path }}" -H "host:{{ 网关关联域名 }}" -H "reqHeader:reqHeaderValue"
56+
```
57+
58+
## 删除
59+
60+
```shell
61+
curl -v -H "Content-Type:application/json" http://{{ hango-portal ip:port }}/gdashboard?PluginBindingInfoId={{ 插件ID }}&Action=UnbindingPlugin&Version=2019-09-01
62+
```
63+
64+
## 界面配置方法
65+
66+
[插件界面配置方法引导](plugin-configuring-guide.md)

docs/plugin/ua-restriction.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# UA黑白名单
2+
3+
## 描述
4+
5+
`ua-restriction`插件可以针对来源于不同User-Agent(用户代理)的请求进行黑名单或白名单限制
6+
7+
## 属性
8+
9+
| 名称 | 类型 | 必选项 | 范围 | 描述 |
10+
|-------------------|---------|-----|---------------------------------------------------|--------------------------|
11+
| kind | string || ua-restriction | 插件类型(值固定) |
12+
| type | integer || [0, 1] | UA黑白名单策略<br/>0:黑名单;1:白名单 |
13+
| list[].match_type | string || exact_match<br/>prefix_match<br/>safe_regex_match | UA黑白名单策略 |
14+
| list[].value | string || length <= 200 | User-Agent值 |
15+
16+
17+
## 前置条件
18+
19+
以下curl命令中存在变量,使用前需要替换为真实环境数据,变量以`{{}}`符号包裹,例如`{{ 网关ID }}`需要根据网关的实际ID进行替换;创建插件命令中`PluginConfiguration`(插件配置)需要根据实际需要进行配置
20+
21+
## 创建
22+
23+
```shell
24+
curl -XPOST -v -H "Content-Type:application/json" -d '{
25+
"BindingObjectId": {{ 路由ID }},
26+
"BindingObjectType": "routeRule",
27+
"GwId": {{ 网关ID }},
28+
"PluginConfiguration": "{\"type\":\"0\",\"list\":[{\"match_type\":\"exact_match\",\"value\":[\"testUA\"]}],\"kind\":\"ua-restriction\"}",
29+
"PluginType": "ua-restriction"
30+
}' http://{{ hango-portal ip:port }}/gdashboard?Action=BindingPlugin&Version=2019-09-01
31+
```
32+
33+
## 测试
34+
35+
```shell
36+
## 修改如下请求的User-Agent参数,与插件配置的UA值一致,测试黑白名单效果
37+
curl -v "http://{{ 网关IP }}/{{ 路由path }}" -H "host:{{ 网关关联域名 }}" -H "User-Agent:xxx"
38+
```
39+
40+
## 删除
41+
42+
```shell
43+
curl -v -H "Content-Type:application/json" http://{{ hango-portal ip:port }}/gdashboard?PluginBindingInfoId={{ 插件ID }}&Action=UnbindingPlugin&Version=2019-09-01
44+
```
45+
46+
## 界面配置方法
47+
48+
[插件界面配置方法引导](plugin-configuring-guide.md)

0 commit comments

Comments
 (0)