0.0
No commit activity in last 3 years
No release in over 3 years
Ditto
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.2.9
>= 0

Runtime

>= 1.1.0
 Project Readme

rack-acceptable

Adds a #acceptable_media_types method to Rack::Request objects so that full-featured content-negotiation can be performed.

Examples

env['HTTP_ACCEPT']  #=> 'application/xml;q=0.8,text/html,text/plain;q=0.9'

req = Rack::Request.new(env)
req.acceptable_media_types          #=> ['text/html', 'text/plain', 'application/xml']

req.acceptable_media_types.prioritize('application/xml', 'text/html') #=>  ['text/html', application/xml']
req.acceptable_media_types.preference_of('text/plain', 'text/html')   #=>  'text/html'
req.acceptable_media_types.first_acceptable('image/png', 'text/html') #=>  'text/html'

See spec/acceptable_media_types_spec.rb for more.