diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2015-09-30 11:23:00 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2015-09-30 11:23:00 -0700 |
commit | 8f8b7ae1d8fd8b17674d70f5bbddabfc3629a7e7 (patch) | |
tree | 31d08a1be0743978fc4bf4c878df7aaffcdc18b2 /railties/lib/rails | |
parent | ff30db1372f2d6c3ac47fe5b0ffb7ca21390f3c1 (diff) | |
download | rails-8f8b7ae1d8fd8b17674d70f5bbddabfc3629a7e7.tar.gz rails-8f8b7ae1d8fd8b17674d70f5bbddabfc3629a7e7.tar.bz2 rails-8f8b7ae1d8fd8b17674d70f5bbddabfc3629a7e7.zip |
only construct one request in an engine
Diffstat (limited to 'railties/lib/rails')
-rw-r--r-- | railties/lib/rails/application.rb | 16 | ||||
-rw-r--r-- | railties/lib/rails/engine.rb | 15 |
2 files changed, 17 insertions, 14 deletions
diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index e3716992f5..175965e565 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -156,15 +156,6 @@ module Rails self end - # Implements call according to the Rack API. It simply - # dispatches the request to the underlying middleware stack. - def call(env) - req = ActionDispatch::Request.new env - env["ORIGINAL_FULLPATH"] = req.fullpath - env["ORIGINAL_SCRIPT_NAME"] = req.script_name - super(env) - end - # Reload application routes regardless if they changed or not. def reload_routes! routes_reloader.reload! @@ -517,6 +508,13 @@ module Rails private + def build_request(env) + req = super + env["ORIGINAL_FULLPATH"] = req.fullpath + env["ORIGINAL_SCRIPT_NAME"] = req.script_name + req + end + def build_middleware config.app_middleware + super end diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index a9d98a9d92..c4bb7d2109 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -523,11 +523,8 @@ module Rails # Define the Rack API for this engine. def call(env) - env.merge!(env_config) - req = ActionDispatch::Request.new env - req.routes = routes - req.engine_script_name = req.script_name - app.call(env) + req = build_request env + app.call req.env end # Defines additional Rack env configuration that is added on each call. @@ -697,6 +694,14 @@ module Rails private + def build_request(env) + env.merge!(env_config) + req = ActionDispatch::Request.new env + req.routes = routes + req.engine_script_name = req.script_name + req + end + def build_middleware config.middleware end |