Class: Psc::Faraday::AcceptPscTypes
- Inherits:
-
Object
- Object
- Psc::Faraday::AcceptPscTypes
- 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
-
#call(env) ⇒ Object
Sets the Accept header if appropriate.
-
#initialize(app) ⇒ AcceptPscTypes
constructor
A new instance of AcceptPscTypes.
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 |