class Faraday::Response::Middleware

Used for simple response middleware.

Public Instance Methods

call(env) click to toggle source
# 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) click to toggle source

Override this to modify the environment after the response has finished. Calls the `parse` method if defined

# 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