提交 c2511f93 编写于 作者: J Joshua Peek 提交者: Carl Lerche & Yehuda Katz

Make dispatcher instances immutable

上级 d7751036
......@@ -66,7 +66,8 @@ def cleanup_application
define_callbacks :prepare_dispatch, :before_dispatch, :after_dispatch
def initialize
@app = @@middleware.build(lambda { |env| self.dup._call(env) })
@app = @@middleware.build(lambda { |env| self._call(env) })
freeze
end
def call(env)
......@@ -74,8 +75,18 @@ def call(env)
end
def _call(env)
@env = env
dispatch
begin
run_callbacks :before_dispatch
Routing::Routes.call(env)
rescue Exception => exception
if controller ||= (::ApplicationController rescue Base)
controller.call_with_exception(env, exception).to_a
else
raise exception
end
ensure
run_callbacks :after_dispatch, :enumerator => :reverse_each
end
end
def flush_logger
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册