Module: Castle::Core::GetConnection
- Defined in:
- lib/castle/core/get_connection.rb
Overview
this module returns a new configured Net::HTTP object
Class Method Summary collapse
Class Method Details
.call(config = nil) ⇒ Net::HTTP
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/castle/core/get_connection.rb', line 10 def call(config = nil) config ||= Castle.config http = Net::HTTP.new(config.base_url.host, config.base_url.port) # `request_timeout` is in milliseconds for historical reasons; both # Net::HTTP timeouts take seconds. timeout_seconds = config.request_timeout / 1000.0 http.open_timeout = timeout_seconds http.read_timeout = timeout_seconds if config.base_url.scheme == 'https' http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_PEER end http end |