https://api.xxx.com/books/
https://api.xxx.com/books/
get
|post
:https://api.xxx.com/books/
get
|put
|patch
|delet
:https://api.xxx.com/books/(?P<pk>)/
https://api.xxx.com/books/v1/
https://api.xxx.com/v2/books/
https://api.xxx.com/books/?publish=1&ordering=-price&limit=3
网络状态码:2xx | 3xx | 4xx | 5xx
数据状态码(自己合前端商量约定的):0 | 1 | 2
{
'status': 1,
}
-- SUCCESS(0, "查询成功")
-- NODATA(1, "非正确,无数据,显示基本信息")
-- FEAILED(2, "查询失败")
常见的网络状态码
状态码 | 说明 |
---|---|
200 | 获取或修改成功 |
201 | 新增成功 |
204 | 删除成功 |
404 | 资源不存在 |
400 | 客户请求有误 |
500 | 服务器错误 |
实际开发中最好返回消息