Class: Foederati::FaradayMiddleware::ParseUnsupportedContentTypes

Inherits:
FaradayMiddleware::ResponseMiddleware
  • Object
show all
Defined in:
lib/foederati/faraday_middleware.rb

Overview

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.

Instance Method Summary collapse

Instance Method Details

#process_response(env) ⇒ Object



12
13
14
15
16
17
# File 'lib/foederati/faraday_middleware.rb', line 12

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