def connection
      @connection ||= Faraday.new(base_url, :builder_class => Saddle::RackBuilder) do |connection|
        # Include the requester level options
        connection.builder.saddle_options[:client_options] = @options

        # Config options
        connection.options[:timeout] = @timeout
        connection.builder.saddle_options[:request_style] = @request_style
        connection.builder.saddle_options[:num_retries] = @num_retries
        connection.builder.saddle_options[:client] = @parent_client

        # Support default return values upon exception
        connection.use(Saddle::Middleware::Response::DefaultResponse)

        # Hard timeout on the entire request
        connection.use(Saddle::Middleware::RubyTimeout)

        # Set up a user agent
        connection.use(Saddle::Middleware::Request::UserAgent)

        # Set up the path prefix if needed
        connection.use(Saddle::Middleware::Request::PathPrefix)

        # Apply additional implementation-specific middlewares
        @additional_middlewares.each do |m|
          m[:args] ? connection.use(m[:klass], *m[:args]) : connection.use(m[:klass])
        end

        # Request encoding
        connection.use(Saddle::Middleware::Request::JsonEncoded)
        connection.use(Saddle::Middleware::Request::UrlEncoded)

        # Automatic retries
        connection.use(Saddle::Middleware::Request::Retry)

        # Raise exceptions on 4xx and 5xx errors
        connection.use(Saddle::Middleware::Response::RaiseError)

        # Handle parsing out the response if it's JSON
        connection.use(Saddle::Middleware::Response::ParseJson)

        # Set up instrumentation around the adapter for extensibility
        connection.use(FaradayMiddleware::Instrumentation)

        # Add in extra env data if needed
        connection.use(Saddle::Middleware::ExtraEnv)

        # Set up our adapter
        if @stubs.nil?
          # Use the default adapter
          connection.adapter(@http_adapter[:key], *@http_adapter[:args])
        else
          # Use the test adapter
          connection.adapter(:test, @stubs)
        end
      end
    end
def connection
      @connection ||= Faraday.new(base_url, :builder_class => Saddle::RackBuilder) do |connection|
        # Include the requester level options
        connection.builder.saddle_options[:client_options] = @options

        # Config options
        connection.options[:timeout] = @timeout
        connection.builder.saddle_options[:request_style] = @request_style
        connection.builder.saddle_options[:num_retries] = @num_retries
        connection.builder.saddle_options[:client] = @parent_client

        # Support default return values upon exception
        connection.use(Saddle::Middleware::Response::DefaultResponse)

        # Hard timeout on the entire request
        connection.use(Saddle::Middleware::RubyTimeout)

        # Set up a user agent
        connection.use(Saddle::Middleware::Request::UserAgent)

        # Set up the path prefix if needed
        connection.use(Saddle::Middleware::Request::PathPrefix)

        # Apply additional implementation-specific middlewares
        @additional_middlewares.each do |m|
          m[:args] ? connection.use(m[:klass], *m[:args]) : connection.use(m[:klass])
        end

        # Request encoding
        connection.use(Saddle::Middleware::Request::JsonEncoded)
        connection.use(Saddle::Middleware::Request::UrlEncoded)

        # Automatic retries
        connection.use(Saddle::Middleware::Request::Retry)

        # Raise exceptions on 4xx and 5xx errors
        connection.use(Saddle::Middleware::Response::RaiseError)

        # Handle parsing out the response if it's JSON
        connection.use(Saddle::Middleware::Response::ParseJson)

        # Set up instrumentation around the adapter for extensibility
        connection.use(FaradayMiddleware::Instrumentation)

        # Add in extra env data if needed
        connection.use(Saddle::Middleware::ExtraEnv)

        # Set up our adapter
        if @stubs.nil?
          # Use the default adapter
          connection.adapter(@http_adapter[:key], *@http_adapter[:args])
        else
          # Use the test adapter
          connection.adapter(:test, @stubs)
        end
      end
    end
Build a connection instance, wrapped in the middleware that we want