REST: What are my OPTIONS ?
Thursday, April 24th, 2008I was reading a post on the blog by Simon Harris about a suggested RESTful way of requesting information in ranges, and I wondered why we don’t use the OPTIONS keyword more, since we appear to be right at home with GET, PUT, POST and DELETE?
There is no standard for REST that I am aware of and maybe this is the reason and maybe we need someone to champion a draft or suggested ’standard’ for using REST and REST-enabling web sites.
I’d like to propose that sites use OPTIONS to enable a method of discovering what resources a site exposes. For example, an OPTIONS request to www.acme.co may respond with an XML representation like this (this is rough but I’m sure you can follow it):
<resources>
<services>
<service name="consulting" uri="/consulting"/>
<service name="support" uri="/support"/>
</services>
<products>
<product name="acme torch" uri="/product/torch"/>
<product name="acme battery" uri="/product/battery"/>
</products>
<gateways>
<gateway name="shopping cart" uri="/cart"/>
</gateways>
</resources>
From this the whole offering of the site is discoverable in a reasonably uniform way. Further OPTIONS request would make possible finer inquiry into the supported options and functionality.
This approach would keep the HEADers free to do what they do in regards the client to server conversation and the supported representations of resources.
If we all took this approach then clients could become smarter and provide more automated and regular features on top of the human readable site. Imagine asking your browser to find the cheapest iPod and it going through your bookmarks or google search results and interrogating each site for the best price, heck, it could even make the purchase too.
Want to work more on this, then drop me a line.


