- Building RESTful Web Services with PHP 7
- Haafiz Waheed ud din Ahmad
- 130字
- 2021-07-03 00:02:19
Updating blog post
- Request: PATCH /posts/1?title=Modified%20Post HTTP/1.1
- Response:
{id:1, title:"Modified Post", content:"This is an awesome post", link:"posts/1" }
- Response code: 200 OK
Note, if a blog post with the ID provided (that is 1 in this case) does not exist, it should return the response code 404 that means resource not found.
Also, we have used PATCH instead of PUT for the update since PATCH is used to modify all or some attributes of a record while PUT is used for modifying a whole record just like replacing an old record with a new one. So, if we use PUT and pass only one attribute, the other attributes will become empty. In the case of PATCH, it will only update the attribute that is passed and other attributes remain untouched.
推薦閱讀
- Boost.Asio C++ Network Programming(Second Edition)
- UI設計基礎培訓教程
- Learning Microsoft Windows Server 2012 Dynamic Access Control
- Visual FoxPro程序設計教程
- C/C++算法從菜鳥到達人
- AIRAndroid應用開發(fā)實戰(zhàn)
- Production Ready OpenStack:Recipes for Successful Environments
- Web程序設計(第二版)
- Serverless架構
- Kubernetes源碼剖析
- 軟件測試綜合技術
- 自學Python:編程基礎、科學計算及數(shù)據(jù)分析(第2版)
- Learning Bootstrap 4(Second Edition)
- UML基礎與Rose建模實用教程(第三版)
- Django 3 Web Development Cookbook