Sha256: 0190fd9aa848660374945f3a6577d427211cc7b936eac2d29c8b1c6962fc327c
Contents?: true
Size: 754 Bytes
Versions: 2
Compression:
Stored size: 754 Bytes
Contents
# frozen_string_literal: true require 'faraday_middleware/response_middleware' module Foederati module FaradayMiddleware ## # Response handler for unspported content types returned by provider APIs # # For instance, if upstream APIs break and start returning HTML or text from # load balancers. class ParseUnsupportedContentTypes < ::FaradayMiddleware::ResponseMiddleware def process_response(env) super content_type = env.response_headers['Content-Type'] fail Faraday::ParsingError, %(API responded with Content-Type "#{content_type}" and status #{env[:status]}) end end Faraday::Response.register_middleware unsupported: -> { ParseUnsupportedContentTypes } end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
foederati-0.2.0 | lib/foederati/faraday_middleware.rb |
foederati-0.1.0 | lib/foederati/faraday_middleware.rb |