Sha256: 25b1d3fd960810a71e9f940de13363430c813a7211786d1a408aea8a67cfe033

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

require 'attune/param_flattener'
require "attune/call_dropping"
require "attune/json_logger"
require "attune/net_http_persistent"

module Attune
  # Default options
  module Default
    extend Configurable

    ENDPOINT = "https://api.attune-staging.co".freeze

    # user our version of NetHttpPersistent adapter
    Faraday::Adapter.register_middleware(attune_http_persistent: NetHttpPersistent)

    MIDDLEWARE = Faraday::Builder.new do |builder|
      # Needed for encoding of BATCH GET requests
      builder.use Attune::ParamFlattener

      # Log all requests
      builder.use Attune::CallDropping

      builder.request  :url_encoded

      # Allow one retry per request
      builder.request :retry, 1

      # Log all requests
      builder.use Attune::JsonLogger

      # Raise exceptions for HTTP 4xx/5xx
      builder.response :raise_error

      builder.adapter :attune_http_persistent
    end

    configure do |c|
      c.endpoint = ENDPOINT
      c.middleware = MIDDLEWARE
      c.disabled = false
      c.exception_handler = :raise
      c.timeout = 1
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
attune-1.0.6 lib/attune/default.rb