SDammann.WebApi.Versioning icon indicating copy to clipboard operation
SDammann.WebApi.Versioning copied to clipboard

Use both URL & HTTP Header versioning at the same time

Open Jognu opened this issue 10 years ago • 1 comments

Hi, First, thanks for this great library !

I have a question : is it possible to use versioning with URL for major release, and HTTP Header versioning for minor release ? Exactly like describe here : http://www.vinaysahni.com/best-practices-for-a-pragmatic-restful-api#versioning

Thanks !

Jognu avatar Jul 07 '15 10:07 Jognu

Yes, this shouldn't be a problem. Implement IRequestVersionDetector and register it with the library.

The implementation will look a lot like AcceptHeaderRequestVersionDetector except you will also want to look at the route like RouteKeyVersionDetector.

One way (not the most recommended way though for integrating it into the library) to do it which may be enough for your purposes is to implement IRequestVersionDetector. In the GetVersion implementation you call GetVersion of a AcceptHeaderRequestVersionDetector instance and on a RouteKeyVersionDetector instance. You cast the result to SemVerApiVersion then combine them.

Sebazzz avatar Jul 07 '15 15:07 Sebazzz