Learning Blog

預定調和

RESTful API 的版本控制

| Comments

紀錄一些如何對 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

Github Media Types

Content Negotiation for Resources

Feature Flagging

參考資料

  1. Build APIs You Won’t Hate
  2. Your API versioning is wrong, which is why I decided to do it 3 different wrong ways

Comments