Sha256: 73f5b2840e597dfa6879594ce18be8c5058b5ee6a41d7a1f0359bf7a26a55025

Contents?: true

Size: 772 Bytes

Versions: 8

Compression:

Stored size: 772 Bytes

Contents

# frozen_string_literal: true

module Datadog
  module Transport
    module HTTP
      module API
        # An API configured with adapter and routes
        class Instance
          attr_reader \
            :adapter,
            :headers,
            :spec

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

          def encoder
            spec.encoder
          end

          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
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ddtrace-1.14.0 lib/ddtrace/transport/http/api/instance.rb
ddtrace-1.13.1 lib/ddtrace/transport/http/api/instance.rb
ddtrace-1.13.0 lib/ddtrace/transport/http/api/instance.rb
ddtrace-1.12.1 lib/ddtrace/transport/http/api/instance.rb
ddtrace-1.12.0 lib/ddtrace/transport/http/api/instance.rb
ddtrace-1.11.1 lib/ddtrace/transport/http/api/instance.rb
ddtrace-1.11.0 lib/ddtrace/transport/http/api/instance.rb
ddtrace-1.11.0.beta1 lib/ddtrace/transport/http/api/instance.rb