Class: FaradayMiddleware::ParseYaml

Inherits:
ResponseMiddleware show all
Defined in:
lib/faraday_middleware/response/parse_yaml.rb

Overview

Public: Parse response bodies as YAML.

Warning: This is not backwards compatible with versions of this middleware prior to faraday_middleware v0.12 - prior to this version, we used YAML.load rather than YAMl.safe_load, which exposes serious remote code execution risks - see github.com/ruby/psych/issues/119 for details. If you’re sure you can trust YAML you’re passing, you can set up an unsafe version of this middleware like this:

class UnsafelyParseYaml < FaradayMiddleware::ResponseMiddleware
  dependency do
    require 'yaml'
  end

  define_parser do |body|
    YAML.load body
  end
end

Faraday.new(..) do |config|
  config.use UnsafelyParseYaml
  ...
end

Constant Summary

Constants inherited from ResponseMiddleware

ResponseMiddleware::CONTENT_TYPE

Method Summary

Methods inherited from ResponseMiddleware

#call, define_parser, inherited, #initialize, #parse, #parse_response?, #preserve_raw?, #process_response, #process_response_type?, #response_type

Constructor Details

This class inherits a constructor from FaradayMiddleware::ResponseMiddleware