Class: Instant2fa::Middleware::UnprocessableEntityStatus
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- Instant2fa::Middleware::UnprocessableEntityStatus
- Defined in:
- lib/instant2fa/middleware/unprocessable_entity_status.rb
Instance Method Summary collapse
Instance Method Details
#call(environment) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/instant2fa/middleware/unprocessable_entity_status.rb', line 14 def call(environment) @app.call(environment).on_complete do |env| handle_status(env[:status], env) # look for meta[:status] if env[:body].is_a?(Hash) code = env[:body].fetch("meta", {}).fetch("status", 200).to_i handle_status(code, env) end end rescue Faraday::ConnectionFailed, Faraday::TimeoutError raise Errors::ConnectionError, environment end |