Class: Faraday::Response::Middleware

Inherits:
Middleware show all
Defined in:
lib/faraday/response.rb

Overview

Used for simple response middleware.

Direct Known Subclasses

Logger, RaiseError

Instance Method Summary (collapse)

Methods inherited from Middleware

dependency, #initialize, loaded?, setup_parallel_manager

Constructor Details

This class inherits a constructor from Faraday::Middleware

Instance Method Details

- (Object) call(env)



7
8
9
10
11
# File 'lib/faraday/response.rb', line 7

def call(env)
  @app.call(env).on_complete do |env|
    on_complete(env)
  end
end

- (Object) on_complete(env)

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])
  end
end