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, 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