aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/middleware/notifications.rb
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2010-01-19 13:40:26 +0530
committerPratik Naik <pratiknaik@gmail.com>2010-01-19 13:40:26 +0530
commitc71120e29caddda295c133adfb279870733a3f81 (patch)
treeda81981de36bc146c36cae3bc73cb5020ba05919 /actionpack/lib/action_dispatch/middleware/notifications.rb
parent087b67805e3785159cb4da524ad37782bd182b93 (diff)
parent71d67fc6bd504956bce66e274e6228dd00a814c1 (diff)
downloadrails-c71120e29caddda295c133adfb279870733a3f81.tar.gz
rails-c71120e29caddda295c133adfb279870733a3f81.tar.bz2
rails-c71120e29caddda295c133adfb279870733a3f81.zip
Merge remote branch 'mainstream/master'
Diffstat (limited to 'actionpack/lib/action_dispatch/middleware/notifications.rb')
-rw-r--r--actionpack/lib/action_dispatch/middleware/notifications.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/notifications.rb b/actionpack/lib/action_dispatch/middleware/notifications.rb
new file mode 100644
index 0000000000..01d2cbb435
--- /dev/null
+++ b/actionpack/lib/action_dispatch/middleware/notifications.rb
@@ -0,0 +1,24 @@
+module ActionDispatch
+ # Provide notifications in the middleware stack. Notice that for the before_dispatch
+ # and after_dispatch notifications, we just send the original env, so we don't pile
+ # up large env hashes in the queue. However, in exception cases, the whole env hash
+ # is actually useful, so we send it all.
+ class Notifications
+ def initialize(app)
+ @app = app
+ end
+
+ def call(stack_env)
+ env = stack_env.dup
+ ActiveSupport::Notifications.instrument("action_dispatch.before_dispatch", :env => env)
+
+ ActiveSupport::Notifications.instrument!("action_dispatch.after_dispatch", :env => env) do
+ @app.call(stack_env)
+ end
+ rescue Exception => exception
+ ActiveSupport::Notifications.instrument('action_dispatch.exception',
+ :env => stack_env, :exception => exception)
+ raise exception
+ end
+ end
+end \ No newline at end of file