Faraday::Middleware
# File lib/github_api/request/jsonize.rb, line 12 def call(env) if request_with_body?(env) env[:request_headers][CONTENT_TYPE] ||= MIME_TYPE env[:body] = encode_body env[:body] unless env[:body].respond_to?(:to_str) else # Ensure valid body for put and post requests if [:put, :patch, :post].include? env[:method] env[:body] = encode_body({}) end end @app.call env end
# File lib/github_api/request/jsonize.rb, line 25 def encode_body(value) if MultiJson.respond_to?(:dump) MultiJson.dump(value) else MultiJson.encode(value) end end
Don’t encode bodies in string form
# File lib/github_api/request/jsonize.rb, line 39 def has_body?(env) body = env[:body] and !(body.respond_to?(:to_str) and body.empty?) end
Generated with the Darkfish Rdoc Generator 2.