Module: Knodes::Connection

Included in:
Client
Defined in:
lib/knodes/connection.rb

Instance Method Summary collapse

Instance Method Details

#connection(raw = false) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/knodes/connection.rb', line 6

def connection(raw=false)
  options = {
     :headers => {'Accept' => "application/#{format}; charset=utf-8", 'User-Agent' => user_agent},
     :proxy => proxy,
     :ssl => {:verify => false},
     :url => endpoint,
   }

  Faraday::Connection.new(options) do |connection|
     connection.request :url_encoded
     connection.response :mashify unless raw
     connection.response :json, content_type: 'application/json' unless raw  
     connection.use FaradayMiddleware::KnodesErrors
     connection.adapter(adapter)
  end
end