I’m just updating my ‘Controller for Mote’ app to work with the new mote-api example and see that, as is fairly common, the API version is embedded in the URIs for the routes.
This means that if you are writing a client app which needs to support multiple API versions, there is no ‘nice’ way to determine the API version a particular host is running, except by starting at the latest and iterating backwards until you find one that works. Right now, there is only one version, but if that changes, it becomes cumbersome.
So for my app, I would need to first call:
And if that failed, then
and so on.
A simple solution to this would be to provide the version via a non-versioned endpoint such as
returning something like
This would then allow clients to call that first, and then build the version specific URIs as appropriate. This is a much nicer mechanism that the iteration approach.
As an aside, while I’m talking versions, is there a reason each route defines the entire URI, or could the common base be pulled out so if it changes (such as for a version change) it only needs to be changed once?
I’m happy to submit pull requests if needed.