Class: ClickHouse::Middleware::ResponseBase
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- ClickHouse::Middleware::ResponseBase
- Defined in:
- lib/click_house/middleware/response_base.rb
Direct Known Subclasses
Constant Summary collapse
- CONTENT_TYPE_HEADER =
'content-type'
Instance Attribute Summary collapse
-
#content_type ⇒ Object
readonly
Returns the value of attribute content_type.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #config ⇒ Config
- #content_type?(env, regexp) ⇒ Boolean
-
#initialize(app = nil, options: {}, content_type: nil, preserve_raw: false) ⇒ ResponseBase
constructor
A new instance of ResponseBase.
Constructor Details
#initialize(app = nil, options: {}, content_type: nil, preserve_raw: false) ⇒ ResponseBase
Returns a new instance of ResponseBase.
11 12 13 14 15 16 17 |
# File 'lib/click_house/middleware/response_base.rb', line 11 def initialize(app = nil, options: {}, content_type: nil, preserve_raw: false) super(app) @options = @content_type = content_type @preserve_raw = preserve_raw on_setup end |
Instance Attribute Details
#content_type ⇒ Object (readonly)
Returns the value of attribute content_type.
9 10 11 |
# File 'lib/click_house/middleware/response_base.rb', line 9 def content_type @content_type end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
8 9 10 |
# File 'lib/click_house/middleware/response_base.rb', line 8 def @options end |
Instance Method Details
#config ⇒ Config
34 35 36 |
# File 'lib/click_house/middleware/response_base.rb', line 34 def config .fetch(:config) end |
#content_type?(env, regexp) ⇒ Boolean
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/click_house/middleware/response_base.rb', line 22 def content_type?(env, regexp) case regexp when NilClass false when Regexp regexp.match?(String(env[:response_headers][CONTENT_TYPE_HEADER])) else raise ArgumentError, "expected regexp got #{regexp.class}" end end |