REST
- 什么是REST?
REST只是一种设计风格,而不是规范。
后端将资源发布为URI,前端通过URI访问资源,并通过HTTP动词表示要对资源进行的操作。
如下:右侧的风格是RESTFUL
GET /rest/api/getDogs --> GET /rest/api/dogs 获取所有小狗狗
GET /rest/api/addDogs --> POST /rest/api/dogs 添加一个小狗狗
GET /rest/api/editDogs/:dog_id --> PUT /rest/api/dogs/:dog_id 修改一个小狗狗
GET /rest/api/deleteDogs/:dog_id --> DELETE /rest/api/dogs/:dog_id 删除一个小狗狗
- 看Url就知道要什么
- 看http method就知道干什么
- 看http status code就知道结果如何