Class: Datadog::Core::Transport::HTTP::API::Instance
- Inherits:
-
Object
- Object
- Datadog::Core::Transport::HTTP::API::Instance
- Defined in:
- lib/datadog/core/transport/http/api/instance.rb
Overview
An API configured with adapter and routes
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
Instance Method Summary collapse
- #call(env) ⇒ Object
- #encoder ⇒ Object
-
#initialize(endpoint, adapter, options = {}) ⇒ Instance
constructor
A new instance of Instance.
Constructor Details
#initialize(endpoint, adapter, options = {}) ⇒ Instance
Returns a new instance of Instance.
15 16 17 18 19 |
# File 'lib/datadog/core/transport/http/api/instance.rb', line 15 def initialize(endpoint, adapter, = {}) @endpoint = endpoint @adapter = adapter @headers = .fetch(:headers, {}) end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
10 11 12 |
# File 'lib/datadog/core/transport/http/api/instance.rb', line 10 def adapter @adapter end |
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
10 11 12 |
# File 'lib/datadog/core/transport/http/api/instance.rb', line 10 def endpoint @endpoint end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
10 11 12 |
# File 'lib/datadog/core/transport/http/api/instance.rb', line 10 def headers @headers end |
Instance Method Details
#call(env) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/datadog/core/transport/http/api/instance.rb', line 25 def call(env) # Add headers to request env, unless empty. env.headers.merge!(headers) unless headers.empty? # Send request env to the adapter. adapter.call(env) end |
#encoder ⇒ Object
21 22 23 |
# File 'lib/datadog/core/transport/http/api/instance.rb', line 21 def encoder endpoint.encoder end |