Sha256: e4a0a484a2d91fa25cb366abfb75e7f238c21d753d8959d403892a92c31aa986

Contents?: true

Size: 786 Bytes

Versions: 13

Compression:

Stored size: 786 Bytes

Contents

# frozen_string_literal: true

# To load ActiveSupport::IsolatedExecutionState on activesupport 7.
# https://github.com/r7kamura/weneedfeed/issues/19
require 'active_support'

require 'active_support/core_ext/array/conversions'
require 'active_support/core_ext/hash/conversions'
require 'faraday'
require 'faraday_middleware/response_middleware'
require 'json'

module Weneedfeed
  class FaradayResponseMiddleware < ::FaradayMiddleware::ResponseMiddleware
    define_parser do |body, options|
      options ||= {}
      options = { dasherize: false }.merge(options)
      object = ::JSON.parse(body)
      object.to_xml(options)
    end

    # @note Overriding.
    def parse_response?(env)
      env.response.headers['Content-Type'].to_s.include?('application/json')
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
weneedfeed-0.20.0 lib/weneedfeed/faraday_response_middleware.rb
weneedfeed-0.19.3 lib/weneedfeed/faraday_response_middleware.rb
weneedfeed-0.19.2 lib/weneedfeed/faraday_response_middleware.rb
weneedfeed-0.19.1 lib/weneedfeed/faraday_response_middleware.rb
weneedfeed-0.19.0 lib/weneedfeed/faraday_response_middleware.rb
weneedfeed-0.18.0 lib/weneedfeed/faraday_response_middleware.rb
weneedfeed-0.17.0 lib/weneedfeed/faraday_response_middleware.rb
weneedfeed-0.16.1 lib/weneedfeed/faraday_response_middleware.rb
weneedfeed-0.16.0 lib/weneedfeed/faraday_response_middleware.rb
weneedfeed-0.15.0 lib/weneedfeed/faraday_response_middleware.rb
weneedfeed-0.14.0 lib/weneedfeed/faraday_response_middleware.rb
weneedfeed-0.13.0 lib/weneedfeed/faraday_response_middleware.rb
weneedfeed-0.12.0 lib/weneedfeed/faraday_response_middleware.rb