Sha256: 83b94f9c3da5fdb2858723d563aaf1b58d07907da9bf6095eaa5e02eea9ae8ab

Contents?: true

Size: 922 Bytes

Versions: 1

Compression:

Stored size: 922 Bytes

Contents

require 'faraday'
require 'oahu/request/auth'
require 'faraday_middleware/response/parse_json'
require 'faraday_middleware/response/caching'

module Oahu
  module Connection
  private

    # Returns a Faraday::Connection object
    #
    # @param options [Hash] A hash of options
    # @return [Faraday::Connection]
    def connection(options={})
      default_options = {
        :headers => {
          :accept => 'application/json',
          :user_agent => user_agent,
        },
        :ssl => {:verify => false},
        :url => options.fetch(:endpoint, endpoint),
      }
      @connection ||= Faraday.new(default_options.deep_merge(connection_options)) do |builder|
        builder.use Oahu::Request::Auth, credentials
        builder.use FaradayMiddleware::Caching, cache_store unless cache_store.nil?
        builder.use FaradayMiddleware::ParseJson
        builder.adapter(adapter)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
oahu-0.0.1 lib/oahu/connection.rb