Sha256: 97da50d6cd890e732066089f9bdf1ac5a305c027bba7083f566ae5122c3015b9

Contents?: true

Size: 750 Bytes

Versions: 2

Compression:

Stored size: 750 Bytes

Contents

# frozen_string_literal: true

module Envkeeper
  class HTTP
    class << self
      def get(path:, body: nil, headers: {})
        request = Net::HTTP::Get.new(path)
        headers.each { |header| request[header] = headers[header] }
        request.set_form_data(body) if body
        http_request.start { |http| http.request(request) }
      end

      private

      REQUEST_URI = 'https://envkeeper.dev/'

      def uri
        URI(REQUEST_URI)
      end

      def http_request
        @http_request ||= create_new_http_request
      end

      def create_new_http_request
        http = Net::HTTP.new(uri.host, uri.port)
        http.use_ssl = true
        http.verify_mode = OpenSSL::SSL::VERIFY_NONE
        http
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
envkeeper-0.1.2 lib/envkeeper/http.rb
envkeeper-0.1.1 lib/envkeeper/http.rb