Class: Faraday::Response::Json
- Inherits:
-
Middleware
- Object
- Middleware
- Faraday::Response::Json
- Defined in:
- lib/faraday/response/json.rb
Overview
Parse response bodies as JSON.
Constant Summary
Constants inherited from Middleware
Middleware::DEFAULT_OPTIONS, Middleware::LOCK
Instance Attribute Summary
Attributes inherited from Middleware
Instance Method Summary collapse
-
#initialize(app = nil, parser_options: nil, content_type: /\bjson$/, preserve_raw: false) ⇒ Json
constructor
A new instance of Json.
- #on_complete(env) ⇒ Object
Methods inherited from Middleware
#call, #close, default_options, default_options=
Methods included from MiddlewareRegistry
#lookup_middleware, #register_middleware, #registered_middleware, #unregister_middleware
Constructor Details
#initialize(app = nil, parser_options: nil, content_type: /\bjson$/, preserve_raw: false) ⇒ Json
Returns a new instance of Json.
9 10 11 12 13 14 15 16 |
# File 'lib/faraday/response/json.rb', line 9 def initialize(app = nil, parser_options: nil, content_type: /\bjson$/, preserve_raw: false) super(app) @parser_options = @content_types = Array(content_type) @preserve_raw = preserve_raw end |
Instance Method Details
#on_complete(env) ⇒ Object
18 19 20 |
# File 'lib/faraday/response/json.rb', line 18 def on_complete(env) process_response(env) if parse_response?(env) end |