Skip to content

Commit

Permalink
add Faraday::Response::Middleware#on_complete hook
Browse files Browse the repository at this point in the history
  • Loading branch information
technoweenie committed Feb 27, 2011
1 parent 1ad9b6b commit 8eaebc2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/faraday/response.rb
Expand Up @@ -5,10 +5,15 @@ class Response
class Middleware < Faraday::Middleware class Middleware < Faraday::Middleware
def call(env) def call(env)
env[:response].on_complete do |finished_env| env[:response].on_complete do |finished_env|
finished_env[:body] = parse(finished_env[:body]) on_complete(finished_env)
end end
@app.call(env) @app.call(env)
end end

# Override this to modify the environment after the response has finished.
def on_complete(env)
env[:body] = parse(env[:body])
end
end end


extend AutoloadHelper extend AutoloadHelper
Expand Down

0 comments on commit 8eaebc2

Please sign in to comment.