Class: Psc::Faraday::AcceptPscTypes

Inherits:
Object
  • Object
show all
Defined in:
lib/psc/faraday/accept_psc_types.rb

Overview

Middleware which sets the Accept header to application/json,text/xml if it is not already set.

Constant Summary collapse

DEFAULT_ACCEPT_HEADER =
'application/json,text/xml'

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ AcceptPscTypes

Returns a new instance of AcceptPscTypes.



11
12
13
# File 'lib/psc/faraday/accept_psc_types.rb', line 11

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object

Sets the Accept header if appropriate



17
18
19
20
21
# File 'lib/psc/faraday/accept_psc_types.rb', line 17

def call(env)
  env[:request_headers]['Accept'] ||= DEFAULT_ACCEPT_HEADER

  @app.call(env)
end