Class: Shark::Middleware::Status
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- Shark::Middleware::Status
- Defined in:
- lib/shark/middleware/status.rb
Instance Method Summary collapse
Instance Method Details
#call(environment) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/shark/middleware/status.rb', line 6 def call(environment) @app.call(environment).on_complete do |env| handle_status(env[:status], env) if env[:body].is_a?(Hash) status = env[:body].fetch('meta', {}).fetch('status', 200).to_i handle_status(status, env) end end rescue Faraday::ConnectionFailed, Faraday::TimeoutError => e raise ConnectionError, e end |