Class: Faraday::Response::Middleware
- Inherits:
-
Middleware
- Object
- Middleware
- Faraday::Response::Middleware
- Defined in:
- lib/faraday/response.rb
Overview
Used for simple response middleware.
Direct Known Subclasses
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#on_complete(env) ⇒ Object
Override this to modify the environment after the response has finished.
Methods inherited from Middleware
dependency, inherited, #initialize, loaded?, new
Methods included from MiddlewareRegistry
#fetch_middleware, #load_middleware, #lookup_middleware, #middleware_mutex, #register_middleware
Constructor Details
This class inherits a constructor from Faraday::Middleware
Instance Method Details
#call(env) ⇒ Object
7 8 9 10 11 |
# File 'lib/faraday/response.rb', line 7 def call(env) @app.call(env).on_complete do |environment| on_complete(environment) end end |
#on_complete(env) ⇒ Object
Override this to modify the environment after the response has finished. Calls the ‘parse` method if defined
15 16 17 |
# File 'lib/faraday/response.rb', line 15 def on_complete(env) env.body = parse(env.body) if respond_to?(:parse) && env.parse_body? end |