对WebAPIs版本的最佳办法是什么?
我正从头开始制作一个API,我想确保它在未来的版面会很优雅。 我设想了类似我的网站.com/api/v2/...
我看到的一种办法是为每种版本的API创建一个单独的项目(网络应用程序),但也许有更好的办法做到这一点吗?
谢谢你的想法
对WebAPIs版本的最佳办法是什么?
我正从头开始制作一个API,我想确保它在未来的版面会很优雅。 我设想了类似我的网站.com/api/v2/...
我看到的一种办法是为每种版本的API创建一个单独的项目(网络应用程序),但也许有更好的办法做到这一点吗?
谢谢你的想法
URL 中包含版本号是标准方法, 正如我在本文中解释的(我不再重复内容): 执行以 WCF 或 AP.Net Api 版本的“STPI ”
您不需要创建一个全新的项目, 尽管您可以。 您将面临一个单一项目的问题, 问题是名称会相撞 :
/api/v1.0/car/123
和
/api/v2.0/car/123
both will point to CarController
while you can have only one of those. The solution would be to implement your own IHttpControllerSelector
和 register with the DependencyResolver. This implementation will look at the version number 和 perhaps find the type based on the namespace.
我不打算在这里引发REST争议。 但正如@DarrelMiller指出,
我个人认为 URL 版本是前进之路。
您需要创建您对 IHtpcrosselector
的自有执行程序。 最好的方法是以 Microsoft s IHtpcrosselector code> 为基础实施此程序。 然后您可以在
IHtpcrosserector
中做出决定, 如果您想要通过 URL 或内容类型版本版本 。
最基本的实施直接实施 IHttpcrosselector
,并刚实施 SecretCrosser
方法,但性能方面的原因,是最好在它周围执行一些缓存。
为查找主计长,您可以使用 IHttpnacentTypeResolver
实例, 使用 Htp Configation. services
, 获取 。
我曾经使用过这样的东西:http://damsteen.nl/blog/protement-version-in-asp.net-web-api 。还在Github上加了一些代码:。
I am using Web API to download a file. Let me first preface that this is new territory for me. My download function inside the Web API code will initiate a download if I go directly to the API s ...
Is there any API provided by Indian Railways to search its train network, time-tables etc. There are many sites out there which show time-table etc. I searched Google but couldn t find any info on Web ...
I m building some Silverlight applications in my spare time, and I wanted find some freely available web services or APIs that I can call. Any suggestions?
I ve got a web API that provides data to users without authentication (the website lets users post data, after they ve logged in using traditional cookies & sessions). Someone wants to develop an ...
Ok, I wanting to database a small library. I ve only had limited experience with databases, and none with querying from a webserver. I m going to want to retrieve information like title, Publisher, ...
I recently found a movie organizer application which fetches its data from the IMDB database. Does IMDB provide an API for this, or any third party APIs available?
Google web APIs have a Python library. Google Alerts has an email and an RSS feed. Does anyone know of an automated way to add Google Alerts through a web API in Python? That is, without clicking. ...
I ve got a list of 6,000 company names (along with their headquarters address) and I need to find the web address for each of them. I m considering using the Google Web API (obviously this will take a ...