lib/restforce/concerns/connection.rb
def connection
        @connection ||= Faraday.new(options[:instance_url],
                                    connection_options) do |builder|
          # Parses JSON into Hashie::Mash structures.
          unless (options[:mashify] == false)
            builder.use    Restforce::Middleware::Mashify, self, options
          end

          # Handles multipart file uploads for blobs.
          builder.use      Restforce::Middleware::Multipart
          # Converts the request into JSON.
          builder.request  :json
          # Handles reauthentication for 403 responses.
          if authentication_middleware
            builder.use    authentication_middleware, self, options
          end
          # Sets the oauth token in the headers.
          builder.use      Restforce::Middleware::Authorization, self, options
          # Ensures the instance url is set.
          builder.use      Restforce::Middleware::InstanceURL, self, options
          # Caches GET requests.
          builder.use      Restforce::Middleware::Caching, cache, options if cache
          # Follows 30x redirects.
          builder.use      FaradayMiddleware::FollowRedirects
          # Raises errors for 40x responses.
          builder.use      Restforce::Middleware::RaiseError
          # Parses returned JSON response into a hash.
          builder.response :json, content_type: /\bjson$/
          # Compress/Decompress the request/response
          builder.use      Restforce::Middleware::Gzip, self, options
          # Inject custom headers into requests
          builder.use      Restforce::Middleware::CustomHeaders, self, options
          # Log request/responses
          builder.use      Restforce::Middleware::Logger,
                           Restforce.configuration.logger,
                           options if Restforce.log?

          builder.adapter  adapter
        end
      end
# Internal: Internal faraday connection where all requests go through
Internal faraday connection where all requests go through
Internal faraday connection where all requests go through
def connection
        @connection ||= Faraday.new(options[:instance_url],
                                    connection_options) do |builder|
          unless (options[:mashify] == false)
            builder.use    Restforce::Middleware::Mashify, self, options
          end
          builder.use      Restforce::Middleware::Multipart
          builder.request  :json
          if authentication_middleware
            builder.use    authentication_middleware, self, options
          end
          builder.use      Restforce::Middleware::Authorization, self, options
          builder.use      Restforce::Middleware::InstanceURL, self, options
          builder.use      Restforce::Middleware::Caching, cache, options if cache
          builder.use      FaradayMiddleware::FollowRedirects
          builder.use      Restforce::Middleware::RaiseError
          builder.response :json, content_type: /\bjson$/
          builder.use      Restforce::Middleware::Gzip, self, options
          builder.use      Restforce::Middleware::CustomHeaders, self, options
          builder.use      Restforce::Middleware::Logger,
                           Restforce.configuration.logger,
                           options if Restforce.log?
          builder.adapter  adapter
        end
      end
def connection @connection ||= Faraday . new ( options [ :instance_url ] , connection_options ) do | builder | unless ( options [ :mashify ] == false ) builder . use Restforce :: Middleware :: Mashify , self , options end builder . use Restforce :: Middleware :: Multipart builder . request :json if authentication_middleware builder . use authentication_middleware , self , options end builder . use Restforce :: Middleware :: Authorization , self , options builder . use Restforce :: Middleware :: InstanceURL , self , options builder . use Restforce :: Middleware :: Caching , cache , options if cache builder . use FaradayMiddleware :: FollowRedirects builder . use Restforce :: Middleware :: RaiseError builder . response :json , content_type : / \b json$ / builder . use Restforce :: Middleware :: Gzip , self , options builder . use Restforce :: Middleware :: CustomHeaders , self , options builder . use Restforce :: Middleware :: Logger , Restforce . configuration . logger , options if Restforce . log? builder . adapter adapter end end
Internal: Internal faraday connection where all requests go through
Internal : Internal faraday connection where all requests go through
# Parses JSON into Hashie::Mash structures. # Handles multipart file uploads for blobs. # Converts the request into JSON. # Handles reauthentication for 403 responses. # Sets the oauth token in the headers. # Ensures the instance url is set. # Caches GET requests. # Follows 30x redirects. # Raises errors for 40x responses. # Parses returned JSON response into a hash. # Compress/Decompress the request/response # Inject custom headers into requests # Log request/responses