mjijackson/rack-accept — pull request #12 by kamui (2013-01-08 01:11:22+00:00)
Title: accept-extension parameter support

The http spec includes accept header extensions. So other than the `q` value, you can actually add arbitrary parameters. We want to use accept-extensions for version api numbers. It looks like this:

```
Accept: application/vnd.example-com.foo+json;version=1.0;q=0.1
```

I wanted to use `rack-accept` since it handles ordering by q values and filtering out the best type based on an array of supported media types, but `rack-accept` assumes that the q value is the only parameter, and that it'll be right after the semicolon. If I use the header above, the result I get is this:

```ruby
accept.qvalues
=> {"application/vnd.example.com.foo+json;version=1.0"=>0.1}
```

`rack-accept` thinks that the version is part of the media type. Also, since everything after the q value is thrown out, there's no way to get the other parameters, such as version without manually parsing out the raw Accept header.

Looking at how `rack-accept` works, you assume only the media type and the q value and you store them as a hash, but it would be cool if the media type returns were an array of hashes that looks like this:

```ruby
{
"application/vnd.example.com.foo+json" : {
"q" : 0.1,
"version" : "1.0",
... other params ...
}
}
```

Resources:
http://www.informit.com/articles/article.aspx?p=1566460
http://publish.luisrei.com/articles/rest.html
http://blog.steveklabnik.com/posts/2011-07-03-nobody-understands-rest-or-http
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html