Class: Restless::Middleware::RequestInfo
- Inherits:
-
Object
- Object
- Restless::Middleware::RequestInfo
- Defined in:
- lib/restless/rack.rb
Overview
Read-only view of the request, handed to the setup callback.
Instance Attribute Summary collapse
-
#env ⇒ Object
readonly
Returns the value of attribute env.
Instance Method Summary collapse
-
#header(name) ⇒ Object
(also: #[])
Case-insensitive, accepts either
Authorizationorauthorization. -
#initialize(env) ⇒ RequestInfo
constructor
A new instance of RequestInfo.
- #path ⇒ Object
- #query_string ⇒ Object
- #request_method ⇒ Object
- #url ⇒ Object
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
#env ⇒ Object (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 |
#path ⇒ Object
94 95 96 |
# File 'lib/restless/rack.rb', line 94 def path "#{@env['SCRIPT_NAME']}#{@env['PATH_INFO']}" end |
#query_string ⇒ Object
98 99 100 |
# File 'lib/restless/rack.rb', line 98 def query_string @env["QUERY_STRING"].to_s end |
#request_method ⇒ Object
90 91 92 |
# File 'lib/restless/rack.rb', line 90 def request_method @env["REQUEST_METHOD"] end |
#url ⇒ Object
102 103 104 |
# File 'lib/restless/rack.rb', line 102 def url Middleware.full_url(@env) end |