Class: HostedGraphite::HTTP

Inherits:
Protocol show all
Defined in:
lib/hosted_graphite/protocols/http.rb

Constant Summary

Constants inherited from Protocol

Protocol::API_URI, Protocol::HOST, Protocol::PORT

Instance Method Summary collapse

Methods inherited from Protocol

#api_key, #send_metric

Constructor Details

#initializeHTTP

Returns a new instance of HTTP.



4
5
6
7
8
9
10
# File 'lib/hosted_graphite/protocols/http.rb', line 4

def initialize
  super
  @uri = URI(API_URI)
  @http = Net::HTTP.new(@uri.host, @uri.port)
  @http.use_ssl = true
  @http.verify_mode = OpenSSL::SSL::VERIFY_NONE
end

Instance Method Details

#send_message(message) ⇒ Object



12
13
14
15
16
17
# File 'lib/hosted_graphite/protocols/http.rb', line 12

def send_message(message)
  req = Net::HTTP::Post.new(@uri.request_uri)
  req.basic_auth api_key, nil
  req.body = message
  @http.request(req)
end