Design and implement web API URLs

quite often there are tips for developing API URLs, where the URLs are in the format "/ api / v1 / resource", and then when the API changes, we can change to / api / v 2, etc.

Now this should be somehow implemented. There are several options:

  • deploy the project to the root of the web server and let the routing rules take care of working with the / api / v 1 part
  • project deployment in / api / subfolder (virtual directory), routing rules take care of parts / v 1, / v2, etc., but do not know about / api / part of URLs.
  • deployment of the project in the subfolder / api / v 1 (virtual directory). The new version of the API is a new project that is being deployed separately. The project is strictly related to resources as the root concept, but, as a rule, does not know about the / api / vX part.

So which method would you choose and why?

Regards, DANIEL

+6
source share
1 answer

I deployed my project to the root folder, and my routing rules handle version control routes. I prefer that my implementation is as little as possible related to my hosting environment if I want to deploy an environment that does not support my implementation method.

SDammann.WebApi.Versioning is the solution I used to achieve this in one of my applications.

However, ASP.NET and the web tools for releasing Visual Studio 2013 will make this even easier.

0
source

Source: https://habr.com/ru/post/955212/


All Articles