Suppose I read a lot about restil api versioning, and I decided not to update this service via uri, but using mediatypes (the format and layout in the accept header):
What would be the best way to implement a wcf service or a web api service to serve requests defining the requested resource in uri format (e.g. application / json) and schema / version (e.g. player-v2) in the accept header?
WCF allows me to route based on uri, but not based on headers. Therefore, I cannot route correctly.
Web Api allows me to define custom mediatypeformatters, routing for the requested format, but not a scheme (for example, the return type PlayerV1 or PlayerV2).
I would like to implement a service (with WCF or Web Api), which for this request (pseudocode):
api.myservice.com/players/123 Accept format=application/json; schema=player-v1
returns a PlayerV1 object in json format
and for this request:
api.myservice.com/players/123 Accept format=application/json; schema=player-v2
returns a PlayerV2 object in json format.
Any tips on how to implement this?
EDIT . To find out why I want to use content negotiation for versioning, see here: REST API Design: put “Type” in “Content Type” .
source
share