Sha256: f738aa1e3b1f8107580b705dff65d6585b42197266da3dc57b9725403bd497e9

Contents?: true

Size: 557 Bytes

Versions: 1

Compression:

Stored size: 557 Bytes

Contents

require 'net/http'
require 'uri'
require 'json'
require 'trav3/result'

module Trav3
  module GET
    def self.call(url, headers = {})
      uri = URI(url)
      req = Net::HTTP::Get.new(uri.request_uri)
      headers.each_pair { |header, value|
        req[header] = value
      }
      http = Net::HTTP.new(uri.host, uri.port)
      http.use_ssl = (uri.scheme == "https")
      response = http.request(req)

      if Net::HTTPOK == response.code_type
        Success.new(response)
      else
        RequestError.new(response)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
trav3-0.1.0 lib/trav3/get.rb