Class: Restless::Middleware::RequestInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/restless/rack.rb

Overview

Read-only view of the request, handed to the setup callback.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env) ⇒ RequestInfo

Returns a new instance of RequestInfo.



75
76
77
# File 'lib/restless/rack.rb', line 75

def initialize(env)
  @env = env
end

Instance Attribute Details

#envObject (readonly)

Returns the value of attribute env.



73
74
75
# File 'lib/restless/rack.rb', line 73

def env
  @env
end

Instance Method Details

#header(name) ⇒ Object Also known as: []

Case-insensitive, accepts either Authorization or authorization.



80
81
82
83
84
85
86
87
# File 'lib/restless/rack.rb', line 80

def header(name)
  key = "HTTP_#{name.to_s.upcase.tr('-', '_')}"
  return @env[key] if @env.key?(key)
  return @env["CONTENT_TYPE"] if key == "HTTP_CONTENT_TYPE"
  return @env["CONTENT_LENGTH"] if key == "HTTP_CONTENT_LENGTH"

  nil
end

#pathObject



94
95
96
# File 'lib/restless/rack.rb', line 94

def path
  "#{@env['SCRIPT_NAME']}#{@env['PATH_INFO']}"
end

#query_stringObject



98
99
100
# File 'lib/restless/rack.rb', line 98

def query_string
  @env["QUERY_STRING"].to_s
end

#request_methodObject



90
91
92
# File 'lib/restless/rack.rb', line 90

def request_method
  @env["REQUEST_METHOD"]
end

#urlObject



102
103
104
# File 'lib/restless/rack.rb', line 102

def url
  Middleware.full_url(@env)
end