要求
仿造github设计一个博客网站的REST API
获取用户所有的articles目录
GET /username/
获取所有的articles摘要
GET /username/articles
获取指定题目的articles细节
GET /username/articles/title
发布articles使用POST请求
POST /username/articles
更新文章使用PUT
PUT /username/articles/helloworld
删除一篇文章根据题目
DELETE /username/articles/title
认证报错信息:
403:访问过于频繁或者是未通过身份验证
curl -i https://api.blog.com -u valid_username:valid_password
HTTP/1.1 403 Forbidden
{
"message": "Maximum number of login attempts exceeded. Please try again later.",
"documentation_url": "https://developer.blog.com/v3"
}
401: 验证无效
curl -i https://api.blog.com -u foo:bar
HTTP/1.1 401 Unauthorized
{
"message": "Bad credentials",
"documentation_url": "https://developer.blog.com/v3"
}
客户端报错信息:
400:无效的JSON格式:
HTTP/1.1 400 Bad Request
Content-Length: 35
{"message":"Problems parsing JSON"}
422:无效字段
HTTP/1.1 422 Unprocessable Entity
Content-Length: 149
{
"message": "Validation Failed",
"errors": [
{
"resource": "Issue",
"field": "title",
"code": "missing_field"
}
]
}