Class: Sinatra::Request

Inherits:
Rack::Request
  • Object
show all
Defined in:
lib/sinatra/base.rb

Overview

The request object. See Rack::Request for more info: rack.rubyforge.org/doc/classes/Rack/Request.html

Instance Method Summary collapse

Instance Method Details

#acceptObject

Returns an array of acceptable media types for the response



16
17
18
# File 'lib/sinatra/base.rb', line 16

def accept
  @env['HTTP_ACCEPT'].to_s.split(',').map { |a| a.split(';')[0].strip }
end

#forwarded?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/sinatra/base.rb', line 32

def forwarded?
  @env.include? "HTTP_X_FORWARDED_HOST"
end

#path_info=(value) ⇒ Object



43
44
45
46
# File 'lib/sinatra/base.rb', line 43

def path_info=(value)
  @route = nil
  super
end

#routeObject



36
37
38
39
40
41
# File 'lib/sinatra/base.rb', line 36

def route
  @route ||= begin
    path = Rack::Utils.unescape(path_info)
    path.empty? ? "/" : path
  end
end