No commit activity in last 3 years
No release in over 3 years
Rack middleware for simplified handling of Accept header. Accept header parser.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
 Project Readme

Summary

Rack convenience middleware to simplify handling of Accept header env['HTTP_ACCEPT']. 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.

Install

gem install rack-accept-media-types

Example

require 'rack/accept_media_types'

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

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

Links