- 获取所有所支持的端口分类
- 用户注册
- 用户登陆
- 获取博客分类列表
- 创建分类列表(需合法token)
- 更新分类列表(需合法token)
- 删除分类(需合法token)
- 获取某个分类内的文章
- 获取某个文章
- 创建新文章(需合法token)
- 更新文章(需合法token)
- 删除文章(需合法token)
- 获取文章的评论
- 添加评论(需合法token)
- 注:
获取所有所支持的端口分类
Request
url: /v1(GET)
用户注册
Request
url: /v1/user(PUT)
1
2
3
4
5
6
7
8
9
```
{
"username": ""
"password": "",
"captcha_id": "",
"captcha_code": "",
"createtime": YYYY-MM-DDTHH:MM:SSZ
}
```
Response
1
2
3
4
5
{
"id": 1
"user_name": ""
}
status code: 201
用户登陆
Request
url: /v1/user/(POST)
1
2
3
4
5
6
7
{
"username": ""
"password": "",
"captcha_id": "",
"captcha_code": "",
"created_at": YYYY-MM-DDTHH:MM:SSZ
}
Response
成功:
1
2
3
4
5
{
"login_token": "",
"expires_time": 0
}
status code: 201 OK
错误:
1
2
3
4
5
{
"message": "Invalid password",
"documentation_url": ""
}
status code: 401 Unauthorized
过多尝试禁止:
1
2
3
4
5
{
"message": "attempts too much!",
"documentation_url": ""
}
status code: 403 Forbidden
获取博客分类列表
Request
url: /v1/blog/categories(GET)
Response
1
2
3
4
5
6
7
8
9
10
{
"categories"[
{
"cate_id": "0",
"cate_name": "",
"art_count": 0
}],
...
}
status code: 200 OK
创建分类列表(需合法token)
Request
/v1/blog/categories(POST)
1
2
3
{
"name": ""
}
Response
1
2
3
4
5
{
"id": 0,
"cate_name": ""
}
status code: 201
更新分类列表(需合法token)
Request
url: /v1/blog/categories/{category_id}(PUT)
1
2
3
{
"name": ""
}
Response
1
2
3
4
5
6
7
{
"id": 0,
"name": ""
"short_cut": "",
"content": ""
}
status code: 200 OK
删除分类(需合法token)
Request
url: /v1/blog/categories/{category_id}(DELETE)
1
2
3
{
"name": ""
}
Response
1
2
3
4
{
"status": "",
}
status code: 204 No Content
获取某个分类内的文章
Request
url: /v1/blog/categories/{category_id}(GET)
Response
1
2
3
4
5
6
7
8
9
10
11
12
13
14
{
"category": "",
"articles": [
{
"id": 0,
"title": "",
"author": "",
"created_at": YYYY-MM-DDTHH:MM:SSZ,
"short_content": ""
},
]
...
}
status code: 200 OK
获取某个文章
Request
url: /v1/blog/articles/{article_id}(GET)
Response
1
2
3
4
5
6
7
8
9
{
"id": 0,
"category_id": 0,
"category_name": "",
"author": "",
"title": "",
"content": ""
}
status code: 200 OK
创建新文章(需合法token)
Request
url: /v1/blog/article(PUT)
1
2
3
4
5
6
{
"category_id": 0,
"article_id": 2,
"title": "",
"content": ""
}
Response
1
2
3
4
5
6
7
8
{
"categoryId": 0,
"article_id": 0,
"title": "",
"content": ""
"created_at": YYYY-MM-DDTHH:MM:SSZ
}
status code: 201
更新文章(需合法token)
Request
url: /v1/blog/articles/{article_id}(PUT)
1
2
3
4
5
6
{
"category_id": 0,
"article_id": 0,
"title": "",
"content": ""
}
Response
1
2
3
4
5
6
7
8
{
"categoryId": 0,
"article_id": 0,
"created_at":YYYY-MM-DDTHH:MM:SSZ
"updated_at":YYYY-MM-DDTHH:MM:SSZ
"url": ""
}
status code: 200 OK
删除文章(需合法token)
Request
url: /v1/blog/articles/{article_id}(DELETE)
Response
1
2
3
4
{
"message": ""
}
status code: 204 No Content
获取文章的评论
Request
url: /v1/blog/articles/{article_id}/comments(GET)
Response Status: 200 OK
1
2
3
4
5
6
7
8
9
10
{
"id": "0",
"user": {
"id": 0,
"username": "",
},
"content": "",
"created_at": YYYY-MM-DDTHH:MM:SSZ
},
Status: 200 OK
添加评论(需合法token)
Request
url: /v1/blog/articles/{article_id}/comments(POST)
1
2
3
{
"content": ""
}
Response
1
2
3
4
5
6
7
{
"id": 0,
"article_title": ""
"content": "",
"createdAt": YYYY-MM-DDTHH:MM:SSZ
}
status code: 200 OK
注:
若有请求内容错误(例如请求要求为json但没有检查到json)或解析失败会返回以下响应:
1
2
3
4
5
{
message: "",
"documentation_url": ""
}
status code: 400 Bad Request
json无效字段:
1
2
3
4
{ "message": "Validation Failed",
"errors": [ { "resource": "Issue", "field": "title", "code": "missing_field" } ]
}
status code: 422 Unprocessable Entity
使用无效凭证:
1
2
3
4
5
{
"message": "",
"documentation_url": ""
}
status code: 401 Unauthorized
短时间多次使用无效凭证:
1
2
3
4
5
{
"message": "attempts too much!",
"documentation_url": ""
}
status code: 403 Forbidden