Sha256: 554c8f1b9ddd5057f6ff2e0d9b8659fa30364d686c55069ed1d8ebf31830c836
Contents?: true
Size: 751 Bytes
Versions: 3
Compression:
Stored size: 751 Bytes
Contents
require 'json' require 'net/http' module Spectator # Helper for HTTP requests class Http # Create a new instance using the given registry # to record stats for the requests performed def initialize(registry) @registry = registry end # Send a JSON payload to a given endpoing def post_json(endpoint, payload) s = payload.to_json uri = URI(endpoint) http = Net::HTTP.new(uri.host, uri.port) req = Net::HTTP::Post.new(uri.path, 'Content-Type' => 'application/json') req.body = s begin res = http.request(req) rescue StandardError => e Spectator.logger.info("Cause #{e.cause} - msg=#{e.message}") return 400 end res.value end end end
Version data entries
3 entries across 3 versions & 2 rubygems
Version | Path |
---|---|
netflix-spectator-rb-0.1.3 | lib/spectator/http.rb |
netflix-spectator-rb-0.1.1 | lib/spectator/http.rb |
spectator-rb-0.1.0 | lib/spectator/http.rb |