Sha256: d54a732cb8eb77c0b3e1127107533fd557121049e3f6360fbdec4ff4e4e7dae6

Contents?: true

Size: 1.41 KB

Versions: 2

Compression:

Stored size: 1.41 KB

Contents

# frozen_string_literal: true
module Slack
  module Web
    module Faraday
      module Connection
        private

        def connection
          @connection ||=
            begin
              options = {
                headers: { 'Accept' => 'application/json; charset=utf-8' }
              }

              options[:headers]['User-Agent'] = user_agent if user_agent
              options[:proxy] = proxy if proxy
              options[:ssl] = { ca_path: ca_path, ca_file: ca_file } if ca_path || ca_file

              request_options = {}
              request_options[:timeout] = timeout if timeout
              request_options[:open_timeout] = open_timeout if open_timeout
              options[:request] = request_options if request_options.any?

              ::Faraday::Connection.new(endpoint, options) do |connection|
                connection.use ::Faraday::Request::Multipart
                connection.use ::Faraday::Request::UrlEncoded
                connection.use ::Slack::Web::Faraday::Response::RaiseError
                connection.use ::FaradayMiddleware::Mashify, mash_class: Slack::Messages::Message
                connection.use ::FaradayMiddleware::ParseJson
                connection.use ::Slack::Web::Faraday::Response::WrapError
                connection.response :logger, logger if logger
                connection.adapter adapter
              end
            end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
slack-ruby-client-1.0.0 lib/slack/web/faraday/connection.rb
slack-ruby-client-0.17.0 lib/slack/web/faraday/connection.rb