Class: Authsignal::Middleware::JsonResponse
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- Authsignal::Middleware::JsonResponse
- Defined in:
- lib/authsignal/middleware/json_response.rb
Instance Method Summary collapse
Instance Method Details
#on_complete(env) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/authsignal/middleware/json_response.rb', line 6 def on_complete(env) ## # NOTE: Response header has "content-type: text/plain" atm # Otherwise, we can safe guard with: env.response_headers['content-type'] =~ /application\/json/ parsed_body = JSON.parse(env.body) if parsed_body.is_a?(Hash) parsed_body.delete("actionCode") # Remove deprecated actionCode from response env.body = transform_to_snake_case(parsed_body) end rescue JSON::ParserError # noop end |