Sha256: e3c528bd9cbd3aff9b834716a3098bf8ecc34f1c276f5f6046f5d7e80932627a
Contents?: true
Size: 911 Bytes
Versions: 5
Compression:
Stored size: 911 Bytes
Contents
require 'net/http' require 'json' module Chillout class HttpClient class NotSent < StandardError attr_reader :original_exception def initialize(original_exception) @original_exception = original_exception end end MEDIA_TYPE = "application/vnd.chillout.v1+json" def initialize(config, logger) @config = config @logger = logger end def post(path, data) http = Net::HTTP.new(@config.hostname, @config.port) http.use_ssl = @config.ssl request_spec = Net::HTTP::Post.new(path) request_spec.body = JSON.dump(data) request_spec.content_type = MEDIA_TYPE request_spec.basic_auth @config.authentication_user, @config.authentication_password http.start do http.request(request_spec) end rescue => e @logger.error("#{e.class}: #{e.message}") raise NotSent.new(e) end end end
Version data entries
5 entries across 5 versions & 1 rubygems