Sha256: 94306f6f3237e6fdc218dc4b80d57930415fc9eeae0335c32edd7b88547d0014
Contents?: true
Size: 848 Bytes
Versions: 11
Compression:
Stored size: 848 Bytes
Contents
require "net/http" require "openssl" module AkamaiCCU class Client attr_reader :net_klass, :host def initialize(host:, net_klass: Net::HTTP) @host = host @net_klass = net_klass end def call(path:, method: POST, initheader: JSON_HEADER) request(path, method, initheader) yield @request if block_given? Thread.new { http.request(@request) }.value end private def base_uri @base_uri ||= URI("#{SSL}://#{host}") end private def http @http ||= @net_klass.new(base_uri.host, base_uri.port).tap do |http| http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_PEER end end private def request(path, klass = GET, initheader = nil) @request ||= @net_klass.const_get(klass).new(base_uri.merge(path).to_s, initheader) end end end
Version data entries
11 entries across 11 versions & 1 rubygems