java - 如何优雅实现restful接口的版本控制
阿神
阿神 2017-04-18 10:36:10
0
1
413
阿神
阿神

闭关修行中......

reply all (1)
阿神

twitter
https://stream.twitter.com/1.1/statuses/sample.json

google
https://accounts.google.com/o/oauth2/v2/auth

facebook
https://graph.facebook.com/v2.8/oauth/access_token

Add the version parameter to the URL,twitter/google/facebook...is all done this way. Isn't this elegant?twitter/google/facebook...都是这样来做的。这不够优雅吗?
增加版本号就是为了接口能自然过度升级,这必然是需要冗余历史版本的代码。不过做法也有很多种。如果你是在一个应用中实现多版本的支持,那可以直接通过DispatchServlet来做servlet-mapping中即可增加版本号pathIncreasing the version number is so that the interface can be naturally over-upgraded. This must require redundant historical versions of code. But there are many ways to do it. If you are implementing multi-version support in an application, you can directly useDispatchServletto do it. Inservlet-mapping, you can increase the version numberpath.
You can also deploy multiple sets ofdifferent versionsapplications on the backend, and forward the interface to different versions of applications for processing based on therequest address.

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!