Class: Faraday::Request::Yajl

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

Instance Method Summary collapse

Methods inherited from Middleware

#initialize, loaded?, setup_parallel_manager

Constructor Details

This class inherits a constructor from Faraday::Middleware

Instance Method Details

#call(env) ⇒ Object



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

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