Class: Rack::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/sinatra/accept_media_types.rb

Instance Method Summary collapse

Instance Method Details

#accept_media_typesObject

The media types of the HTTP_ACCEPT header ordered according to their “quality” (preference level), without any media type parameters.

Examples
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'

For more information, see:

Returns
AcceptMediaTypes

ordered list of accept header’s media types



21
22
23
# File 'lib/sinatra/accept_media_types.rb', line 21

def accept_media_types
   @accept_media_types ||= Rack::AcceptMediaTypes.new(@env['HTTP_ACCEPT'])
end