Module: Coinbase::Middleware

Defined in:
lib/coinbase/middleware.rb

Overview

A module for middleware that can be used with Faraday.

Class Method Summary collapse

Class Method Details

.configObject

Returns the default middleware configuration for the Coinbase SDK.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/coinbase/middleware.rb', line 15

def self.config
  Coinbase::Client::Configuration.default.tap do |config|
    uri = URI(Coinbase.configuration.api_url)

    config.debugging = Coinbase.configuration.debug_api
    config.host = uri.host + (uri.port ? ":#{uri.port}" : '')
    config.scheme = uri.scheme if uri.scheme
    config.request(:authenticator)
    config.request(:correlation)
    retry_options = {
      max: Coinbase.configuration.max_network_tries,
      interval: 0.05,
      interval_randomness: 0.5,
      backoff_factor: 2,
      methods: %i[get],
      retry_statuses: [500, 502, 503, 504]
    }
    config.configure_faraday_connection do |conn|
      conn.request :retry, retry_options
    end
  end
end