Class: ApiValve::Forwarder::Response
- Inherits:
-
Object
- Object
- ApiValve::Forwarder::Response
- Defined in:
- lib/api_valve/forwarder/response.rb
Overview
This class is wraps the original response. The rack_response method is called by the Forwarder to build the rack response that will be returned by the proxy. By changing this class, we can control how the request is published to the original caller
Constant Summary collapse
- WHITELISTED_HEADERS =
%w( Cache-Control Content-Disposition Content-Type Location ).freeze
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#original_request ⇒ Object
readonly
Returns the value of attribute original_request.
-
#original_response ⇒ Object
readonly
Returns the value of attribute original_response.
Instance Method Summary collapse
-
#initialize(original_request, original_response, options = {}) ⇒ Response
constructor
A new instance of Response.
-
#rack_response ⇒ Object
Must return a rack compatible response array of status code, headers and body.
Constructor Details
#initialize(original_request, original_response, options = {}) ⇒ Response
Returns a new instance of Response.
21 22 23 24 25 |
# File 'lib/api_valve/forwarder/response.rb', line 21 def initialize(original_request, original_response, = {}) @original_request = original_request @original_response = original_response @options = .with_indifferent_access end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
12 13 14 |
# File 'lib/api_valve/forwarder/response.rb', line 12 def @options end |
#original_request ⇒ Object (readonly)
Returns the value of attribute original_request.
12 13 14 |
# File 'lib/api_valve/forwarder/response.rb', line 12 def original_request @original_request end |
#original_response ⇒ Object (readonly)
Returns the value of attribute original_response.
12 13 14 |
# File 'lib/api_valve/forwarder/response.rb', line 12 def original_response @original_response end |
Instance Method Details
#rack_response ⇒ Object
Must return a rack compatible response array of status code, headers and body
28 29 30 |
# File 'lib/api_valve/forwarder/response.rb', line 28 def rack_response Rack::Response.new(body, status, headers) end |