Class: Lurch::Middleware::JSONApiRequest

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/lurch/middleware/json_api_request.rb

Constant Summary collapse

CONTENT_TYPE =
"Content-Type".freeze
ACCEPT =
"Accept".freeze
MIME_TYPE =
"application/vnd.api+json".freeze

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object



12
13
14
15
16
17
# File 'lib/lurch/middleware/json_api_request.rb', line 12

def call(env)
  env[:request_headers][CONTENT_TYPE] = MIME_TYPE
  env[:request_headers][ACCEPT] = MIME_TYPE
  env[:body] = JSON.generate(env[:body]) if env[:body].is_a?(Hash)
  @app.call(env)
end