- 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.
推薦閱讀
- FuelPHP Application Development Blueprints
- Beginning Java Data Structures and Algorithms
- JavaScript高效圖形編程
- Network Automation Cookbook
- Git高手之路
- Java面向對象程序開發及實戰
- Learning Firefox OS Application Development
- C程序設計實踐教程
- 新一代SDN:VMware NSX 網絡原理與實踐
- JavaScript從入門到精通(視頻實戰版)
- Python預測分析與機器學習
- SFML Game Development
- Kotlin語言實例精解
- 跟小樓老師學用Axure RP 9:玩轉產品原型設計
- Learning Redux