Sha256: 9f539a9b63e4b248e2efa32757511f13d607fb9e641c663cb0be4c1dc17a0544

Contents?: true

Size: 681 Bytes

Versions: 4

Compression:

Stored size: 681 Bytes

Contents

require 'mrkt/faraday_middleware'

module Mrkt
  module Connection
    def connection
      @connection ||= init_connection
    end

    def init_connection
      Faraday.new(url: "https://#{@host}") do |conn|
        conn.request :multipart
        conn.request :url_encoded

        conn.response :logger, @logger, (@log_options || {}) if @debug
        conn.response :mkto, content_type: /\bjson$/

        conn.options.timeout = @options[:read_timeout] if @options.key?(:read_timeout)
        conn.options.open_timeout = @options[:open_timeout] if @options.key?(:open_timeout)

        conn.adapter @options.fetch(:adapter, Faraday.default_adapter)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mrkt-1.0.0 lib/mrkt/concerns/connection.rb
mrkt-0.11.1 lib/mrkt/concerns/connection.rb
mrkt-0.11.0 lib/mrkt/concerns/connection.rb
mrkt-0.10.0 lib/mrkt/concerns/connection.rb