紀錄一些如何對 RESTful API 進行版本控制的方法。
URI
https://api.example.com/v1/places
Hostname
https://api-v1.example.com/places
Body and Query Params
1 POST /places HTTP/1.1
2 Host: api.example.com
3 Content-Type: application/json
4
5 {
6 "version" : "1.0"
7 }
Custom Request Header
Bad HTTP API Smells: Version Headers
Content Negotiation
Content Negotiation for Resources
Feature Flagging
參考資料
- Build APIs You Won’t Hate
- Your API versioning is wrong, which is why I decided to do it 3 different wrong ways