Sha256: 36a154f4d3e8fc16a1ab7735d48347f145a93409932288f14350254e728a2bf7
Contents?: true
Size: 621 Bytes
Versions: 4
Compression:
Stored size: 621 Bytes
Contents
require 'faraday' require 'json' module Twitter module REST module Response class ParseJson < Faraday::Response::Middleware def parse(body) case body when /\A^\s*$\z/, nil nil else JSON.parse(body, :symbolize_names => true) end end def on_complete(env) if respond_to?(:parse) env[:body] = parse(env[:body]) unless unparsable_status_codes.include?(env[:status]) end end def unparsable_status_codes [204, 301, 302, 304] end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems