Class: LogErrorHandler::HttpOut

Inherits:
Object
  • Object
show all
Defined in:
lib/log_error_handler/http_out.rb

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ HttpOut

Returns a new instance of HttpOut.



3
4
5
6
# File 'lib/log_error_handler/http_out.rb', line 3

def initialize(opts)
  @options = opts
  @req = Net::HTTP.const_get(@options[:http_method].capitalize).new(@options[:uri])
end

Instance Method Details

#closeObject



17
18
# File 'lib/log_error_handler/http_out.rb', line 17

def close
end

#puts(message) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/log_error_handler/http_out.rb', line 8

def puts(message)
  data = @options[:additional_params] || {}
  data[@options[:error_message_key]] = Base64.encode64(message)
  @req.set_form_data(data)
  http = Net::HTTP.new(@options[:uri].hostname, @options[:uri].port)
  http.use_ssl = @options[:uri].scheme == 'https'
  http.request(@req)
end