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.



88
89
90
# File 'lib/datadog/core/remote/transport/http/negotiation.rb', line 88

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

Instance Method Details

#call(env, &block) ⇒ Object



92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/datadog/core/remote/transport/http/negotiation.rb', line 92

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

  # 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