-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathexample_api.http
More file actions
67 lines (59 loc) · 2.44 KB
/
Copy pathexample_api.http
File metadata and controls
67 lines (59 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
### example-module (Fiber) —— Example 资源 CRUD
###
### 供 VS Code REST Client / JetBrains HTTP Client 使用的手动 API 测试文件。
### 路由由 register_api_router.go 中的 registerExampleRoutes 注册在应用根路径
###(无前缀):
### POST /examples
### GET /examples/:id
### GET /examples
### PUT /examples/:id
### DELETE /examples/:id
###
### 响应信封(response.RespInfo):{"code": int, "msg": string, "data": ...}
### -> 新建资源的 id 位于 JSON 路径 `data.id`。
###
### X-language-flag 头选择校验错误的语言区域(moduleconstant.XLanguageFlag);
### 缺省时 handler 默认为 "en"。
###
### 请自上而下运行:`create` 会填充 {{create.response.body.$.data.id}},
### 供下方的 Get/Update/Delete 请求复用。
@baseUrl = http://localhost:8080
@language = en
### Create —— POST /examples
# 从 CreateExampleReqVo 创建一个新的 example 资源(name 必填;
# description/status/tags 可选)。返回 201,`data` 中为新建的 ExampleRespVo。
# @name create
POST {{baseUrl}}/examples
Content-Type: application/json
X-language-flag: {{language}}
{
"name": "My Example",
"description": "A short description of the example.",
"status": "active",
"tags": ["demo", "swagger"]
}
### Get —— GET /examples/:id
# 按 id 获取上面创建的 example。返回 200,`data` 中为 ExampleRespVo;
# 若 id 不存在,返回 404。
GET {{baseUrl}}/examples/{{create.response.body.$.data.id}}
X-language-flag: {{language}}
### List —— GET /examples
# 分页列出 example,并可按 status 过滤,参数从 ListExamplesReqVo 查询参数
#(page、page_size、status)绑定。返回 200,`data` 中为 ExampleListRespVo
#(items/page/page_size/total)。
GET {{baseUrl}}/examples?page=1&page_size=20&status=active
X-language-flag: {{language}}
### Update —— PUT /examples/:id
# 使用 UpdateExampleReqVo 部分更新上面创建的 example(所有字段可选/指针——
# 省略的字段保持不变)。返回 200,`data` 中为更新后的 ExampleRespVo。
PUT {{baseUrl}}/examples/{{create.response.body.$.data.id}}
Content-Type: application/json
X-language-flag: {{language}}
{
"status": "archived",
"tags": ["demo"]
}
### Delete —— DELETE /examples/:id
# 删除上面创建的 example。成功返回 204 No Content;若 id 不存在,返回 404。
DELETE {{baseUrl}}/examples/{{create.response.body.$.data.id}}
X-language-flag: {{language}}