Sha256: b073ee7e84d362796d4d295cac4966c268d41c94ed0b22c67c0edbc29eff2540

Contents?: true

Size: 473 Bytes

Versions: 2

Compression:

Stored size: 473 Bytes

Contents

module Faraday
  class Request::ActiveSupportJson < Faraday::Middleware
    begin
      if !defined?(ActiveSupport::JSON)
        require 'active_support'
      end

    rescue LoadError => e
      self.load_error = e
    end

    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
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
faraday-0.2.1 lib/faraday/request/active_support_json.rb
faraday-0.2.0 lib/faraday/request/active_support_json.rb