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
adapter?, dependency, inherited, #initialize, loaded?, new
Methods included from MiddlewareRegistry
#lookup_middleware, #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 18 19 |
# File 'lib/faraday/response.rb', line 15 def on_complete(env) if respond_to? :parse env[:body] = parse(env[:body]) unless [204,304].index env[:status] end end |