I'm creating a web API and I want to be able to version it. The way I want to do it is this:
- Client application passes in custom HTTP header with each request containing version of API they're calling against.
- A component (called
IVersionRetrieveror something) exists to pull the version number from the request. Castle Windsor is responsible for providing instances ofIVersionRetriever. - Where I want the implementation of a service interface to vary
between versions, Castle Windsor is configured to check
IVersionRetriever.ApiVersionand return an implementation according to the value obtained.
All this seems simple enough, but I can't work out from Windsor's registration API how I would say to Windsor 'right, for IFoo, if IVersionRetriever.ApiVersion is 1, then I want a SuperFoo, but if the version is 2, then I want a SuperDuperFoo.
How would I configure this?
All components have a PerWebRequest lifestyle, if that's relevant.