Sha256: a4919b7fda40a4c9631a9df13d20f52708cf8e635534f1f65f869cb4c46d7656

Contents?: true

Size: 917 Bytes

Versions: 4

Compression:

Stored size: 917 Bytes

Contents

# frozen_string_literal: true

require 'base64'
require 'json'
require 'logger'
require 'net/http'
require 'openssl'

require 'net/hippie/version'
require 'net/hippie/content_type_mapper'
require 'net/hippie/client'
require 'net/hippie/api'

module Net
  # net/http for hippies.
  module Hippie
    CONNECTION_ERRORS = [
      EOFError,
      Errno::ECONNRESET,
      Errno::EINVAL,
      Net::ProtocolError,
      Timeout::Error
    ].freeze

    def self.logger
      @logger ||= Logger.new(STDOUT)
    end

    def self.logger=(logger)
      @logger = logger
    end

    def self.verify_mode
      @verify_mode ||= OpenSSL::SSL::VERIFY_PEER
    end

    def self.verify_mode=(mode)
      @verify_mode = mode
    end

    def self.basic_auth(username, password)
      "Basic #{::Base64.strict_encode64("#{username}:#{password}")}"
    end

    def self.bearer_auth(token)
      "Bearer #{token}"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
net-hippie-0.2.6 lib/net/hippie.rb
net-hippie-0.2.5 lib/net/hippie.rb
net-hippie-0.2.4 lib/net/hippie.rb
net-hippie-0.2.3 lib/net/hippie.rb