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
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
相关文章推荐
- Servlet 的线程安全问题分析
- 19. jQuery 遍历
- 仿微信6.0笔记
- 微信关注回复代码
- mysql只导出建表语句
- Bootstrap学习:列表组
- Bootstrap学习:面板
- SQL SERVER向后兼容包地址
- epoll两种触发模式的区别
- Django开发中DJANGO_SETTINGS_MODULE is undefined解决方案
- 国内App推广终极37个方法
- Navicat Premium11.0.16 for Mac 破解版中文版,支持10.10
- Bootstrap学习:Wells
- Bootstrap学习:插件概览
- java常用操作
- 从数字到字符串的转换
- Android Dialog
- POJ 3159 差分约束系统 最短路
- 程序员博客是否应该晒代码(由摄影而感)
- 迷你MVVM框架 avalonjs 入门教程