http://web-service.com/resource/1.xmland be presented with an XML representation of the
resourcewith an id of 1 while
http://web-service.com/resource/1.jsongives you a JSON representation and
http://web-service.com/resource/1.htmla HTML version of the same resource. Now, the fact that one of those formats (HTML) is human readable is incidental - yet the temptation exists to try to take this and build an interface which is usable by humans. Real cool, eh? I append
.xmland I have a web service, but if I append
.htmlI get a neat UI.
Sadly, most applications never do just one thing on a particular page. It's a usability thing -
When creating a resource I want to also see the serial number of its parent resource so that <insert valid usability requirement here>. Now this requirement can't be met without polluting your REST service (doing more than just create/retrieve/update/delete with a single URL) - or you could remain a REST purist and piss all your users off.
My point is that a REST application exposes a CRUD interface, while a user application needs to expose a usable interface and you don't want to try mixing the two. If all you're doing is providing a simple, dumb interface for data entry and simple testing (and assuming the real use of your REST application is by other applications consuming services), REST based HTML interfaces may work. But a regular application should never try to exploit the fact that REST services can be rendered as HTML. Always completely separate out your services into a stand alone application and have a second, human usable application consume them. That way, the REST services remain pristine and your users get something they can use without having to bend over backwards first.
(The tendency to start using REST rendered HTML for a UI is something I've observed after a couple of months of working on assorted REST projects. This post was a result of talking to other people in ThoughtWorks who are currently on REST projects as well as a fair number of discussions with Srihari while pairing)