Permalink
Browse files

add Faraday::Response::Middleware#on_complete hook

  • Loading branch information...
1 parent 1ad9b6b commit 8eaebc246c2b533585799069852de9a58f068849 @technoweenie technoweenie committed Feb 27, 2011
Showing with 6 additions and 1 deletion.
  1. +6 −1 lib/faraday/response.rb
View
@@ -5,10 +5,15 @@ class Response
class Middleware < Faraday::Middleware
def call(env)
env[:response].on_complete do |finished_env|
- finished_env[:body] = parse(finished_env[:body])
+ on_complete(finished_env)
end
@app.call(env)
end
+
+ # Override this to modify the environment after the response has finished.
+ def on_complete(env)
+ env[:body] = parse(env[:body])
+ end
end
extend AutoloadHelper

0 comments on commit 8eaebc2

Please sign in to comment.