Class: Request::JsonEncode

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

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/faraday/request/json_encode.rb', line 3

def call(env)
  if env[:request_headers]["Content-Type"] == nil
    env[:body] = MultiJson.encode(env[:body]) if env[:body] != nil
    env[:request_headers]["Content-Type"] = "application/json"
  end
  @app.call(env)
end