Class: Gpdb::HttpClient::HeadersMiddleware

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/gpdb/http_client.rb

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/gpdb/http_client.rb', line 12

def call(env)
  env[:request_headers]['Content-Type'] = if [:post, :put].include?(env.method)
                                            'multipart/form-data'
                                          else
                                            'application/json'
                                          end

  env[:request_headers]['Accept'] = 'application/json'
  env[:request_headers]['User-Agent'] = "gpdb-api-client/#{GpdbClient::VERSION}"

  @app.call(env)
end