seancribbs/webmachine-ruby — pull request #70 by statonjr (2012-09-20 02:12:06+00:00)
Title: Add optional body for OPTIONS method

Section 9.2 of RFC 2616 provides for an optional response body in the OPTIONS method. Section 9.2 further provides that the response body, if any, SHOULD include information about the communication options. The format for such a body is not defined by the specification, but might be defined by future extensions to HTTP. Content negotiation MAY be used to select the appropriate response format. If no response body is included, the response MUST include a Content-Length field with a field-value of "0".

At REST Fest 2012, one of the presenters used the OPTIONS method to provide additional information to API clients in the response body. I tried to implement similar functionality with Webmachine, but could not because the `options` callback only allowed a `Hash` of headers.

I changed the `options` callback to return an Array of two items: a Hash of headers and an array of Content-Type and handler pairs, similar to the `content_types_provided` callback.