Class: LontaraUtilities::HTTPClient::BodyParser
- Inherits:
-
Object
- Object
- LontaraUtilities::HTTPClient::BodyParser
- Defined in:
- lib/lontara_utilities/http_client/body_parser.rb
Overview
Body Parser responsible for parsing body based on content type.
Instance Method Summary collapse
-
#initialize(content_type:, body:) ⇒ BodyParser
constructor
A new instance of BodyParser.
-
#parse ⇒ Object
Parse body based on content type.
Constructor Details
#initialize(content_type:, body:) ⇒ BodyParser
Returns a new instance of BodyParser.
7 8 9 10 |
# File 'lib/lontara_utilities/http_client/body_parser.rb', line 7 def initialize(content_type:, body:) @content_type = content_type @body = body end |
Instance Method Details
#parse ⇒ Object
Parse body based on content type.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/lontara_utilities/http_client/body_parser.rb', line 13 def parse case content_type when 'application/json' body.to_json when 'application/x-www-form-urlencoded' URI.encode_www_form(body) else body end end |