Sha256: 0f0ffc03ec38e9a5eba9a64addbf1d763190759f2bd2e583ec0fe30b46bb2814
Contents?: true
Size: 753 Bytes
Versions: 1
Compression:
Stored size: 753 Bytes
Contents
require 'faraday' require 'json' require 'smartsheet/api/faraday_adapter/faraday_response' module Smartsheet module API module Middleware # Wraps responses into {FaradayResponse FaradayResponses}, parsing JSON bodies when applicable class ResponseParser < Faraday::Middleware def initialize(app) super(app) end def call(env) @app.call(env).on_complete do |response_env| if response_env[:response_headers]['content-type'] =~ /\bjson\b/ response_env[:body] = JSON.parse(response_env[:body], symbolize_names: true) end response_env[:body] = FaradayResponse.from_response_env response_env end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
smartsheet-1.0.0 | lib/smartsheet/api/faraday_adapter/middleware/response_parser.rb |