Class: Request::SerializeJson

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/faraday/request/serialize_json.rb

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/faraday/request/serialize_json.rb', line 9

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