Sumarry
Rack convenience middleware for simplified handling of Accept header (env). Allows ordering of its values (accepted media types) according to their “quality” (preference level).
This wrapper is typically used to determine the request’s prefered media type (see example below).
Install
gem install mynyml-rack-accept-media-types --source=http://gems.github.com/
Examples
env['HTTP_ACCEPT'] #=> 'application/xml;q=0.8,text/html,text/plain;q=0.9'
types = Rack::AcceptMediaTypes.new(env['HTTP_ACCEPT'])
types #=> ['text/html', 'text/plain', 'application/xml']
types.prefered #=> 'text/html'