Class: Datadog::Transport::HTTP::API::Instance

Inherits:
Object
  • Object
show all
Defined in:
lib/ddtrace/transport/http/api/instance.rb

Overview

An API configured with adapter and routes

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(spec, adapter, options = {}) ⇒ Instance

Returns a new instance of Instance.



12
13
14
15
16
# File 'lib/ddtrace/transport/http/api/instance.rb', line 12

def initialize(spec, adapter, options = {})
  @spec = spec
  @adapter = adapter
  @headers = options.fetch(:headers, {})
end

Instance Attribute Details

#adapterObject (readonly)

Returns the value of attribute adapter.



7
8
9
# File 'lib/ddtrace/transport/http/api/instance.rb', line 7

def adapter
  @adapter
end

#headersObject (readonly)

Returns the value of attribute headers.



7
8
9
# File 'lib/ddtrace/transport/http/api/instance.rb', line 7

def headers
  @headers
end

#specObject (readonly)

Returns the value of attribute spec.



7
8
9
# File 'lib/ddtrace/transport/http/api/instance.rb', line 7

def spec
  @spec
end

Instance Method Details

#call(env) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/ddtrace/transport/http/api/instance.rb', line 18

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