Class: BlueprintAgreement::RequestBuilder::RailsRequest
- Inherits:
-
Object
- Object
- BlueprintAgreement::RequestBuilder::RailsRequest
- Defined in:
- lib/blueprint_agreement/request_builder.rb
Constant Summary collapse
- HEADER_PATCH =
{ "CONTENT_TYPE" => "Content-Type", "HTTP_AUTHORIZATION" => "Authorization", "rack.request.cookie_string" => "Cookie", "HTTP_COOKIE" => "Cookie", }
- DEFAULT_HEADERS =
%w[ HTTP_ACCEPT HTTP_ACCEPT_CHARSET HTTP_ACCEPT_ENCODING HTTP_ACCEPT_LANGUAGE HTTP_CACHE_CONTROL HTTP_FROM HTTP_NEGOTIATE HTTP_PRAGMA HTTP_CLIENT_IP HTTP_X_FORWARDED_FOR HTTP_ORIGIN HTTP_VERSION HTTP_X_CSRF_TOKEN HTTP_X_REQUEST_ID HTTP_X_FORWARDED_HOST SERVER_ADDR ].freeze
Instance Method Summary collapse
- #body ⇒ Object
- #content_type ⇒ Object
- #fullpath ⇒ Object
- #headers ⇒ Object
-
#initialize(context) ⇒ RailsRequest
constructor
A new instance of RailsRequest.
- #request ⇒ Object
- #request_method ⇒ Object
Constructor Details
#initialize(context) ⇒ RailsRequest
Returns a new instance of RailsRequest.
73 74 75 |
# File 'lib/blueprint_agreement/request_builder.rb', line 73 def initialize(context) @context = context end |
Instance Method Details
#body ⇒ Object
77 78 79 |
# File 'lib/blueprint_agreement/request_builder.rb', line 77 def body @body ||= request.body.read end |
#content_type ⇒ Object
81 82 83 |
# File 'lib/blueprint_agreement/request_builder.rb', line 81 def content_type request.content_type end |
#fullpath ⇒ Object
89 90 91 |
# File 'lib/blueprint_agreement/request_builder.rb', line 89 def fullpath request.fullpath end |
#headers ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/blueprint_agreement/request_builder.rb', line 93 def headers headers = {} DEFAULT_HEADERS.each do |env| next unless @context.request.env.key?(env) key = env.sub(/^HTTP_/n, '').downcase headers[key] = @context.request.env[env] end HEADER_PATCH.each do |header| header_name, key = header next unless @context.request.env.key?(header_name) headers[key] = @context.request.env[header_name] end headers.compact end |
#request ⇒ Object
111 112 113 |
# File 'lib/blueprint_agreement/request_builder.rb', line 111 def request @context.request end |
#request_method ⇒ Object
85 86 87 |
# File 'lib/blueprint_agreement/request_builder.rb', line 85 def request_method request.request_method end |