Sha256: e3acb246cfc26f2a529e4081b51ce7998a9fc110313f8bcc256b2f4670c92364
Contents?: true
Size: 846 Bytes
Versions: 8
Compression:
Stored size: 846 Bytes
Contents
require 'uri' require 'net/http' module Timezone # @!visibility private # A basic HTTP Client that handles requests to Geonames and Google. # # You can create your own version of this class if you want to use # a proxy or a different http library such as faraday. # # @example # Timezone::Lookup.config(:google) do |c| # c.api_key = 'foo' # c.request_handler = Timezone::NetHTTPClient # end # class NetHTTPClient def initialize(config) uri = URI.parse("#{config.protocol}://#{config.url}") @http = Net::HTTP.new(uri.host, uri.port) @http.open_timeout = config.open_timeout || 5 @http.read_timeout = config.read_timeout || 5 @http.use_ssl = (config.protocol == 'https'.freeze) end def get(url) @http.request(Net::HTTP::Get.new(url)) end end end
Version data entries
8 entries across 8 versions & 1 rubygems