Class: Confy::HttpClient::ResponseHandler
- Inherits:
-
Object
- Object
- Confy::HttpClient::ResponseHandler
- Defined in:
- lib/confy/http_client/response_handler.rb
Overview
ResponseHandler takes care of decoding the response body into suitable type
Class Method Summary collapse
Class Method Details
.get_body(response) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/confy/http_client/response_handler.rb', line 8 def self.get_body(response) type = response.headers["content-type"] body = response.body # Response body is in JSON if type and type.include?("json") begin body = JSON.parse body rescue JSON::ParserError return body end end return body end |