您的位置:首页 > 其它

Web API 版本控制的几种方式

2015-09-02 14:14 141 查看
方式一:利用URL
HTTP GET: 
https://haveibeenpwned.com/api/v2/breachedaccount/foo 
方式二:利用用户自定义的request header
HTTP GET: 
https://haveibeenpwned.com/api/breachedaccount/foo 
api-version: 2 
@Controller
@RequestMapping(headers="api-version=2") 
public class TestControllerV2 { 
}
方式三:利用content type
HTTP GET: 
https://haveibeenpwned.com/api/breachedaccount/foo 
Accept: application/vnd.haveibeenpwned.v2+json 
方式四:利用content type
HTTP GET: 
https://haveibeenpwned.com/api/breachedaccount/foo 
Accept: application/vnd.haveibeenpwned+json; version=2.0 
这个方式和方式三的小不同的地方是,把版本号分离出来了。
方式五:利用URL里的parameter
HTTP GET: 
https://haveibeenpwned.com/api/breachedaccount/foo?v=2 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: