Method: LabClient::HTTP#headers

Defined in:
lib/labclient/http.rb

#headers(dump_json) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/labclient/http.rb', line 44

def headers(dump_json)
  default_headers = {

    'Accept' => 'application/json',
    'User-Agent' => "LabClient #{LabClient::VERSION}"
  }

  token_type = settings[:token_type]
  default_headers[token_type] = if token_type == 'Authorization'
                                  "Bearer #{settings[:token]}"
                                else
                                  settings[:token]
                                end

  default_headers['Content-Type'] = 'application/json' if dump_json

  default_headers
end