Class: Datadog::Core::Remote::Transport::HTTP::Negotiation::API::Endpoint

Inherits:
Transport::HTTP::API::Endpoint show all
Defined in:
lib/datadog/core/remote/transport/http/negotiation.rb

Overview

Endpoint for negotiation

Instance Attribute Summary

Attributes inherited from Transport::HTTP::API::Endpoint

#path, #verb

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Endpoint

Returns a new instance of Endpoint.



117
118
119
# File 'lib/datadog/core/remote/transport/http/negotiation.rb', line 117

def initialize(path)
  super(:get, path)
end

Instance Method Details

#call(env, &block) ⇒ Object



121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/datadog/core/remote/transport/http/negotiation.rb', line 121

def call(env, &block)
  # Query for response
  http_response = super(env, &block)

  # Process the response
  body = JSON.parse(http_response.payload, symbolize_names: true) if http_response.ok?

  # TODO: there should be more processing here to ensure a proper response_options
  response_options = body.is_a?(Hash) ? body : {}

  # Build and return a trace response
  Negotiation::Response.new(http_response, response_options)
end