15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/influxdb/api/client.rb', line 15
def perform_request(method, path, params = {}, body = nil, &block)
method = method.downcase.to_sym unless method.is_a?(Symbol)
response = with_retry(path, params) do |connection, url|
connection.basic_auth(config.user, config.password)
= { 'Content-Type' => 'application/json' }
body = body ? convert_to_json(body) : nil
logger.debug "=> #{method.upcase} #{url} #{body}" if logger
connection.run_request(method, url, body, , &block)
end
logger.debug "<= [#{response.status}] #{response.body}" if logger
raise_transport_error(response) if response.status.to_i >= 300
json = config.serializer.load(response.body) if response. && response.["content-type"] =~ /json/
Response.new(response.status, json || response.body, response.)
ensure
@last_request_at = Time.now
end
|