I am re-designing my previous century app (which works very well, mind you), and the chance to start fresh has me investigating several aspects. This question is re. versioning.
The app is really collection of data apps that deliver resources--query is http and response is JSON. Now I want to change one of the responses. After reading around, I have decided to not implement versioning via the URI or query_string. Instead, as advised in Best practices for API versioning?, especially the second answer (is there not a way on Stackoverflow to link to a specific answer?), I am using headers. However, instead of using Accept: application/vnd.company.myapp.customer-v3+json I am using
Accept: application/json
X-Requested-With: XMLHttpRequest
X-Version: 2
On the server side I am able to check the value for X-Version. If it doesn't exist, the query uses the latest API. It X-Version does exist, then the request version is used. The above works fine.
My question is -- any gotchas I should be aware of? Esp. since I pulled this X-Version out of my butt. As far as I know, it is not an officially sanctioned header.
Update: Drats! even before posting this I read Custom HTTP headers : naming conventions, and it seems I should not use the X- prefix. However, then there is a possibility of my home-grown header conflicting with an existing standard unless I first do due-diligence. Thoughts?
X-Versionrefer to. Specifically, it refers to the resource being requested. In other words, the query is saying, "get me the resource at the end of this URI using the API version 2 which is applicable only to this resource." In other words, other resources can continue use their own respective API versions.