Class: Request
- Inherits:
-
Object
- Object
- Request
- Includes:
- AbstractType, Adamantium::Flat
- Defined in:
- lib/request.rb,
lib/request/key.rb,
lib/request/rack.rb,
lib/request/method.rb,
lib/request/protocol.rb
Overview
Library namespace and abstract base class
Direct Known Subclasses
Defined Under Namespace
Classes: Key, Method, Protocol, Rack
Constant Summary collapse
- KEYS =
%W( path_info protocol port request_method host if_modified_since query_params query_params_hash query_string content_length content_type body ).map(&:to_sym).freeze
- METHODS =
(KEYS + %W(rack_env get? post?)).map(&:to_sym).freeze
Instance Method Summary collapse
-
#absolute_uri ⇒ String
private
Return absolute uri.
-
#absolute_uri_path(path) ⇒ String
private
Return absolute uri for path.
-
#host ⇒ String
private
Return host.
-
#host_with_port ⇒ String
private
Return host with optional port.
-
#if_modified_since ⇒ Time?
private
Return if modified since header.
-
#path_info ⇒ String
private
Return path info.
-
#port ⇒ Integer
private
Return port.
-
#protocol ⇒ Protocol
private
Return protocol.
-
#query_params ⇒ Array
private
Return query params.
-
#query_params_hash ⇒ Hash
private
Return query params hash.
-
#query_string ⇒ String
private
Return query string.
-
#request_method ⇒ Method
private
Return request method.
-
#root_uri ⇒ String
private
Return root uri.
-
#uid ⇒ String
private
Return unique id.
Instance Method Details
#absolute_uri ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return absolute uri
120 121 122 |
# File 'lib/request.rb', line 120 def absolute_uri "#{root_uri}#{path_info}" end |
#absolute_uri_path(path) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return absolute uri for path
132 133 134 |
# File 'lib/request.rb', line 132 def absolute_uri_path(path) "#{root_uri}#{path}" end |
#host ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return host
67 |
# File 'lib/request.rb', line 67 abstract_method :host |
#host_with_port ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return host with optional port
Only returns port if protocols default port diffes from actual port.
155 156 157 158 159 160 161 162 |
# File 'lib/request.rb', line 155 def host_with_port uhost, uport = self.host, self.port if port != protocol.default_port "#{uhost}:#{uport}" else uhost end end |
#if_modified_since ⇒ Time?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return if modified since header
51 |
# File 'lib/request.rb', line 51 abstract_method :if_modified_since |
#path_info ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return path info
59 |
# File 'lib/request.rb', line 59 abstract_method :path_info |
#port ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return port
75 |
# File 'lib/request.rb', line 75 abstract_method :port |
#protocol ⇒ Protocol
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return protocol
39 |
# File 'lib/request.rb', line 39 abstract_method :protocol |
#query_params ⇒ Array
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return query params
91 |
# File 'lib/request.rb', line 91 abstract_method :query_params |
#query_params_hash ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return query params hash
99 100 101 102 103 |
# File 'lib/request.rb', line 99 def query_params_hash query_params.each_with_object({}) do |(key, value), hash| hash[key]=value end end |
#query_string ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return query string
112 |
# File 'lib/request.rb', line 112 abstract_method :query_string |
#request_method ⇒ Method
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return request method
83 |
# File 'lib/request.rb', line 83 abstract_method :request_method |
#root_uri ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return root uri
142 143 144 |
# File 'lib/request.rb', line 142 def root_uri "#{protocol.name}://#{host_with_port}" end |
#uid ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return unique id
28 29 30 |
# File 'lib/request.rb', line 28 def uid SecureRandom.hex(6) end |