SDammann.WebApi.Versioning
SDammann.WebApi.Versioning copied to clipboard
Use both URL & HTTP Header versioning at the same time
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 !
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.