lib/hyper_resource/modules/http.rb
def faraday_connection(url=nil)
        url ||= URI.join(self.root, self.href)
        key = Digest::MD5.hexdigest({
          'faraday_connection' => {
            'url' => url,
            'headers' => self.headers,
            'ba' => self.auth[:basic]
          }
        }.to_json)
        return Thread.current[key] if Thread.current[key]

        fc = Faraday.new(self.faraday_options.merge(:url => url))
        fc.headers.merge!('User-Agent' => "HyperResource #{HyperResource::VERSION}")
        fc.headers.merge!(self.headers || {})
        if ba=self.auth[:basic]
          fc.basic_auth(*ba)
        end
        Thread.current[key] = fc
      end
## Returns a raw Faraday connection to this resource's URL, with proper
## headers (including auth).  Threadsafe.
Returns a raw Faraday connection to this resource's URL, with proper
headers (including auth).  Threadsafe.
Returns a raw Faraday connection to this resource ' s URL with proper headers ( including auth ) . Threadsafe .
def faraday_connection(url=nil)
        url ||= URI.join(self.root, self.href)
        key = Digest::MD5.hexdigest({
          'faraday_connection' => {
            'url' => url,
            'headers' => self.headers,
            'ba' => self.auth[:basic]
          }
        }.to_json)
        return Thread.current[key] if Thread.current[key]
        fc = Faraday.new(self.faraday_options.merge(:url => url))
        fc.headers.merge!('User-Agent' => "HyperResource #{HyperResource::VERSION}")
        fc.headers.merge!(self.headers || {})
        if ba=self.auth[:basic]
          fc.basic_auth(*ba)
        end
        Thread.current[key] = fc
      end
def faraday_connection ( url = nil ) url ||= URI . join ( self . root , self . href ) key = Digest :: MD5 . hexdigest ( { 'faraday_connection' => { 'url' => url , 'headers' => self . headers , 'ba' => self . auth [ :basic ] } } . to_json ) return Thread . current [ key ] if Thread . current [ key ] fc = Faraday . new ( self . faraday_options . merge ( :url => url ) ) fc . headers . merge! ( 'User-Agent' => "HyperResource #{HyperResource::VERSION}" ) fc . headers . merge! ( self . headers || { } ) if ba = self . auth [ :basic ] fc . basic_auth ( * ba ) end Thread . current [ key ] = fc end
Returns a raw Faraday connection to this resource's URL, with proper
headers (including auth).
Returns a raw Faraday connection to this resource ' s URL with proper headers ( including auth ) .
url