Class: Datadog::Core::Remote::Transport::HTTP::API::Instance
- Inherits:
-
Object
- Object
- Datadog::Core::Remote::Transport::HTTP::API::Instance
- Includes:
- Config::API::Instance, Negotiation::API::Instance
- Defined in:
- lib/datadog/core/remote/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.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#spec ⇒ Object
readonly
Returns the value of attribute spec.
Instance Method Summary collapse
- #call(env) ⇒ Object
- #encoder ⇒ Object
-
#initialize(spec, adapter, options = {}) ⇒ Instance
constructor
A new instance of Instance.
Methods included from Config::API::Instance
Methods included from Negotiation::API::Instance
Constructor Details
#initialize(spec, adapter, options = {}) ⇒ Instance
Returns a new instance of Instance.
16 17 18 19 20 |
# File 'lib/datadog/core/remote/transport/http/api/instance.rb', line 16 def initialize(spec, adapter, = {}) @spec = spec @adapter = adapter @headers = .fetch(:headers, {}) end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
11 12 13 |
# File 'lib/datadog/core/remote/transport/http/api/instance.rb', line 11 def adapter @adapter end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
11 12 13 |
# File 'lib/datadog/core/remote/transport/http/api/instance.rb', line 11 def headers @headers end |
#spec ⇒ Object (readonly)
Returns the value of attribute spec.
11 12 13 |
# File 'lib/datadog/core/remote/transport/http/api/instance.rb', line 11 def spec @spec end |
Instance Method Details
#call(env) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/datadog/core/remote/transport/http/api/instance.rb', line 26 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
22 23 24 |
# File 'lib/datadog/core/remote/transport/http/api/instance.rb', line 22 def encoder spec.encoder end |