Sha256: 17889419def069c5a74e42d881c4e7dc452823d23263034fa9e602ed9b584653
Contents?: true
Size: 722 Bytes
Versions: 1
Compression:
Stored size: 722 Bytes
Contents
require 'net/http' module GistDoIt class NetHTTPAdapter def post_with_token(token, uri, data) request = Net::HTTP::Post.new(uri.to_s) add_headers_to_request!(request, {"content-type" => "application/json", "Authorization" => "token #{token}"}) add_body_to_request!(request, data) Net::HTTP.start(uri.host, uri.port, :use_ssl => true) do |http| @response = http.request(request).body end @response end private def add_headers_to_request!(request, headers) headers.each do |header_name, header_value| request[header_name] = header_value end end def add_body_to_request!(request, data) request.body = data end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gistdoit-0.0.1 | lib/gistdoit/net_http_adapter.rb |