Class: Faraday::Request::ActiveSupportJson

Inherits:
Middleware show all
Defined in:
lib/faraday/request/active_support_json.rb

Instance Method Summary collapse

Methods inherited from Middleware

#create_form_params, #full_path_for, #initialize, loaded?, #process_body_for_request, setup_parallel_manager

Constructor Details

This class inherits a constructor from Faraday::Middleware

Instance Method Details

#call(env) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/faraday/request/active_support_json.rb', line 13

def call(env)
  env[:request_headers]['Content-Type'] = 'application/json'
  if env[:body] && !env[:body].respond_to?(:to_str)
    env[:body] = ActiveSupport::JSON.encode(env[:body])
  end
  @app.call env
end