diff options
Diffstat (limited to 'lib/raindrops/middleware.rb')
-rw-r--r-- | lib/raindrops/middleware.rb | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/raindrops/middleware.rb b/lib/raindrops/middleware.rb index ea19ffc..af3442c 100644 --- a/lib/raindrops/middleware.rb +++ b/lib/raindrops/middleware.rb @@ -32,17 +32,18 @@ class Raindrops::Middleware # standard Rack endpoint def call(env) env[PATH_INFO] == @path and return stats_response + begin + @stats.incr_calling - @stats.incr_calling + status, headers, body = @app.call(env) + rv = [ status, headers, Proxy.new(body, @stats) ] - status, headers, body = @app.call(env) - rv = [ status, headers, Proxy.new(body, @stats) ] - - # the Rack server will start writing headers soon after this method - @stats.incr_writing - rv + # the Rack server will start writing headers soon after this method + @stats.incr_writing + rv ensure @stats.decr_calling + end end class Proxy |