Skip to content

Commit 50d2957

Browse files
authored
doc: fix the doc style for serverless*.md (#1511)
1 parent 06acbe9 commit 50d2957

File tree

2 files changed

+27
-13
lines changed

2 files changed

+27
-13
lines changed

doc/plugins/serverless-cn.md

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,29 @@
2020
[English](serverless.md)
2121

2222
# serverless
23+
2324
serverless 的插件有两个,分别是 `serverless-pre-function``serverless-post-function`
2425
前者会在指定阶段的最开始运行,后者是在指定阶段的最后运行。
2526

2627
这两个插件接收的参数都是一样的。
2728

28-
### Parameters
29+
## Parameters
30+
2931
* `phase`: 指定的运行阶段,没有指定的话默认是 `access`。允许的阶段有:`rewrite``access`
3032
`header_filer``body_filter``log``balancer` 阶段。
3133
* `functions`: 指定运行的函数列表,是数组类型,里面可以包含一个函数,也可以是多个函数,按照先后顺序执行。
34+
3235
需要注意的是,这里只接受函数,而不接受其他类型的 Lua 代码。比如匿名函数是合法的:
33-
```
36+
37+
```lua
3438
return function()
3539
ngx.log(ngx.ERR, 'one')
3640
end
3741
```
3842

3943
闭包也是合法的:
40-
```
44+
45+
```lua
4146
local count = 1
4247
return function()
4348
count = count + 1
@@ -46,14 +51,16 @@ end
4651
```
4752

4853
但不是函数类型的代码就是非法的:
49-
```
54+
55+
```lua
5056
local count = 1
5157
ngx.say(count)
5258
```
5359

54-
### 示例
60+
## 示例
61+
62+
### 启动插件
5563

56-
#### 启动插件
5764
下面是一个示例,在指定的 route 上开启了 serverless 插件:
5865

5966
```shell
@@ -75,16 +82,19 @@ curl -i http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f03433
7582
}'
7683
```
7784

78-
#### 测试插件
85+
### 测试插件
86+
7987
使用 curl 访问:
88+
8089
```shell
8190
curl -i http://127.0.0.1:9080/index.html
8291
```
8392

8493
然后你在 error.log 日志中就会发现 `serverless pre function` 这个 error 级别的日志,
8594
表示指定的函数已经生效。
8695

87-
#### 移除插件
96+
### 移除插件
97+
8898
当你想去掉插件的时候,很简单,在插件的配置中把对应的 json 配置删除即可,无须重启服务,即刻生效:
8999

90100
```shell

doc/plugins/serverless.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
[Chinese](serverless-cn.md)
2121

2222
# Summary
23+
2324
- [**Name**](#name)
2425
- [**Attributes**](#attributes)
2526
- [**How To Enable**](#how-to-enable)
@@ -41,16 +42,17 @@ Both plug-ins receive the same parameters.
4142
| phase |optional|The default phase is `access`, if not specified. The valid phases are: `rewrite`, `access`,`Header_filer`, `body_filter`, `log` and `balancer`.|
4243
| functions |required|A list of functions that are specified to run is an array type, which can contain either one function or multiple functions, executed sequentially.|
4344

44-
4545
Note that only function is accepted here, not other types of Lua code. For example, anonymous functions are legal:<br>
46-
```
46+
47+
```lua
4748
return function()
4849
ngx.log(ngx.ERR, 'one')
4950
end
5051
```
5152

5253
Closure is also legal:
53-
```
54+
55+
```lua
5456
local count = 1
5557
return function()
5658
count = count + 1
@@ -59,7 +61,8 @@ end
5961
```
6062

6163
But code that is not a function type is illegal:
62-
```
64+
65+
```lua
6366
local count = 1
6467
ngx.say(count)
6568
```
@@ -90,7 +93,8 @@ curl -i http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f03433
9093
## Test Plugin
9194

9295
Use curl to access:
93-
```shell
96+
97+
```shell
9498
curl -i http://127.0.0.1:9080/index.html
9599
```
96100

0 commit comments

Comments
 (0)