Class: Datadog::Transport::HTTP::API::Instance
- Inherits:
-
Object
- Object
- Datadog::Transport::HTTP::API::Instance
- Defined in:
- lib/ddtrace/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.
Constructor Details
#initialize(spec, adapter, options = {}) ⇒ Instance
Returns a new instance of Instance.
14 15 16 17 18 |
# File 'lib/ddtrace/transport/http/api/instance.rb', line 14 def initialize(spec, adapter, = {}) @spec = spec @adapter = adapter @headers = .fetch(:headers, {}) end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
9 10 11 |
# File 'lib/ddtrace/transport/http/api/instance.rb', line 9 def adapter @adapter end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
9 10 11 |
# File 'lib/ddtrace/transport/http/api/instance.rb', line 9 def headers @headers end |
#spec ⇒ Object (readonly)
Returns the value of attribute spec.
9 10 11 |
# File 'lib/ddtrace/transport/http/api/instance.rb', line 9 def spec @spec end |
Instance Method Details
#call(env) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/ddtrace/transport/http/api/instance.rb', line 24 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
20 21 22 |
# File 'lib/ddtrace/transport/http/api/instance.rb', line 20 def encoder spec.encoder end |