Class: Alephant::Broker::Response::Base
- Inherits:
-
Object
- Object
- Alephant::Broker::Response::Base
- Includes:
- Logger
- Defined in:
- lib/alephant/broker/response/base.rb
Direct Known Subclasses
Constant Summary collapse
- STATUS_CODE_MAPPING =
{ 200 => "ok", 202 => "Accepted", 304 => "", 404 => "Not found", 500 => "Error retrieving content" }.freeze
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(status = 200, content_type = "text/html", request_env = nil) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(status = 200, content_type = "text/html", request_env = nil) ⇒ Base
Returns a new instance of Base.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/alephant/broker/response/base.rb', line 25 def initialize(status = 200, content_type = "text/html", request_env = nil) @content = STATUS_CODE_MAPPING[status] @headers = { "Content-Type" => content_type, "Access-Control-Allow-Headers" => "If-None-Match, If-Modified-Since", "Access-Control-Allow-Origin" => "*" } @headers.merge!(Broker.config[:headers]) if Broker.config.key?(:headers) @status = status add_no_cache_headers if should_add_no_cache_headers?(status) add_etag_allow_header if headers.key?("ETag") setup if status == 200 @content = "" if self.class.(request_env) end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
15 16 17 |
# File 'lib/alephant/broker/response/base.rb', line 15 def content @content end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
15 16 17 |
# File 'lib/alephant/broker/response/base.rb', line 15 def headers @headers end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
15 16 17 |
# File 'lib/alephant/broker/response/base.rb', line 15 def status @status end |