restful api版本控制

restful api版本控制
1.不适用版本
http://xxx.com/api/user/login

2.不适用版本,直接更好api,新功能使用新的api,老版本使用老api
http://xxx.com/api/user/login
http://xxx.com/api/user/newLogin

3.url加上版本号
http://xxx.com/api/v1/user/login
http://xxx.com/api/v2/user/login

4.url参数带版本号
http://xxx.com/api/v1/user/login?version=1
http://xxx.com/api/v1/user/login?version=2
5.使用请求头来区分版本
http://xxx.com/api/user/login
headers=[X-api-version=1]
http://xxx.com/api/user/login
headers=[X-api-version=2]

6.通过媒体类型进行版本控制
http://xxx.com/api/user/login
headers=[Accept=application/api-v1+json]

http://xxx.com/api/user/login
headers=[Accept=application/api-v2+json]

posted @ 2022-03-16 15:12  三号小玩家  阅读(248)  评论(0编辑  收藏  举报
Title
三号小玩家的 Mail: 17612457115@163.com, 联系QQ: 1359720840 微信: QQ1359720840