Class: RfLogger::RequestHeaders
- Inherits:
-
Object
- Object
- RfLogger::RequestHeaders
- Defined in:
- lib/rf_logger/request/request_headers.rb
Instance Attribute Summary collapse
-
#api_token ⇒ Object
readonly
Returns the value of attribute api_token.
-
#content_type ⇒ Object
readonly
Returns the value of attribute content_type.
-
#other ⇒ Object
readonly
Returns the value of attribute other.
-
#request_id ⇒ Object
readonly
Returns the value of attribute request_id.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(type: "application/json", api_token: nil, request_id: self.class.request_id, other: {}, **other_key_headers) ⇒ RequestHeaders
constructor
A new instance of RequestHeaders.
- #other_key_headers ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(type: "application/json", api_token: nil, request_id: self.class.request_id, other: {}, **other_key_headers) ⇒ RequestHeaders
Returns a new instance of RequestHeaders.
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/rf_logger/request/request_headers.rb', line 5 def initialize(type: "application/json", api_token: nil, request_id: self.class.request_id, other: {}, **other_key_headers) @type = type @api_token = api_token @request_id = request_id @content_type = type @other = other @other_key_headers = other_key_headers end |
Instance Attribute Details
#api_token ⇒ Object (readonly)
Returns the value of attribute api_token.
3 4 5 |
# File 'lib/rf_logger/request/request_headers.rb', line 3 def api_token @api_token end |
#content_type ⇒ Object (readonly)
Returns the value of attribute content_type.
3 4 5 |
# File 'lib/rf_logger/request/request_headers.rb', line 3 def content_type @content_type end |
#other ⇒ Object (readonly)
Returns the value of attribute other.
3 4 5 |
# File 'lib/rf_logger/request/request_headers.rb', line 3 def other @other end |
#request_id ⇒ Object (readonly)
Returns the value of attribute request_id.
3 4 5 |
# File 'lib/rf_logger/request/request_headers.rb', line 3 def request_id @request_id end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
3 4 5 |
# File 'lib/rf_logger/request/request_headers.rb', line 3 def type @type end |
Class Method Details
.request_id ⇒ Object
18 19 20 |
# File 'lib/rf_logger/request/request_headers.rb', line 18 def self.request_id (Thread.current.get_inheritable_attribute(:rf_logger_request_tags)||{})[:request_id] end |
Instance Method Details
#other_key_headers ⇒ Object
30 31 32 |
# File 'lib/rf_logger/request/request_headers.rb', line 30 def other_key_headers @other_key_headers.each_with_object({}) { |(k, v), h| h[k.to_s.split("_").map(&:capitalize).join("-")] = v } end |
#to_hash ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/rf_logger/request/request_headers.rb', line 22 def to_hash { "Content-Type" => content_type, "Api-Token" => api_token, "X-Request-Id" => request_id }.merge(other_key_headers).merge(other).reject { |_, v| v.nil? } end |