What should the standard be for ReSTful URLS?
- by gargantaun
Since I can't find a chuffing job, I've been reading up on ReST and creating web services. The way I've interpreted it, the future is all about creating a web service for all your data before you build the web app. Which seems like a good idea.
However, there seems to be a lot of contradictory thoughts on what the best scheme is for ReSTful URLs.
Some people advocate simple pretty urls
http://api.myapp.com/resource/1
In addition, some people like to add the API version to the url like so
http://api.myapp.com/v1/resource/1
And to make things even more confusing, some people advocate adding the content-type to get requests
http://api.myapp.com/v1/resource/1.xml
http://api.myapp.com/v1/resource/1.json
http://api.myapp.com/v1/resource/1.txt
Whereas others think the content-type should be sent in the HTTP header.
Soooooooo.... That's a lot of variation, which has left me unsure of what the best URL scheme is. I personally see the merits of the most comprehensive URL that includes a version number, resource locator and content-type, but I'm new to this so I could be wrong.
On the other hand, you could argue that you should do "whatever works best for you". But that doesn't really fit with the ReST mentality as far as I can tell since the aim is to have a standard.
And since a lot of you people will have more experience than me with ReST, I thought I'd ask for some guidance. So, with all that in mind...
What should the standard be for ReSTful URLS?