【发布时间】:2016-05-11 17:26:39
【问题描述】:
我正在使用一项 restfull 服务,并且有 20 多个客户正在使用该服务。
@Path("/provider")
public class Provider{
@Path("/simpleprovider")
@GET
public String getProvider(){
return "Simple Provider";
}
}
现在我决定推出服务版本,我有很多谷歌,阅读我的文章但我完全困惑我该怎么办?假设我为@Path("/provider/v1") 之类的新服务更改URI,而不是我应该如何为现有客户提供支持?考虑到这件事,每当 api 新版本生效时,我是否必须为每个客户端提供更改?
谷歌搜索后,我发现有 3 种方法可以提供版本控制
URL 版本控制
自定义请求标头
内容类型
但找不到任何实际的例子,请在这方面帮助我
http://stackoverflow.com/questions/389169/best-practices-for-api-versioning http://www.narwhl.com/2015/03/the-ultimate-solution-to-versioning-rest-apis-content-negotiation/ http://restcookbook.com/Basics/versioning/
http://www.troyhunt.com/2014/02/your-api-versioning-is-wrong-which-is.html
http://www.lexicalscope.com/blog/2012/03/12/how-are-rest-apis-versioned/
任何帮助将不胜感激
【问题讨论】:
标签: java api restful-architecture api-versioning