Sha256: 34b89a2db71d1680b1ea6b210efb7cad44df89bf48be561197202cdd8795493d
Contents?: true
Size: 691 Bytes
Versions: 4
Compression:
Stored size: 691 Bytes
Contents
require 'json' module Faye module Authentication class HTTPClient def self.publish(url, channel, data, key) uri = URI(url) req = prepare_request(uri.request_uri, channel, data, key) Net::HTTP.start(uri.hostname, uri.port, :use_ssl => uri.scheme == 'https') { |http| http.request(req) } end def self.prepare_request(uri, channel, data, key) req = Net::HTTP::Post.new(uri) message = {'channel' => channel, 'clientId' => 'http'} message['signature'] = Faye::Authentication.sign(message, key) message['data'] = data req.set_form_data(message: JSON.dump(message)) req end end end end
Version data entries
4 entries across 4 versions & 1 rubygems