aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/middleware.rb
diff options
context:
space:
mode:
authorYehuda Katz <wycats@Yehuda-Katz.local>2009-11-05 15:38:04 -0800
committerYehuda Katz <wycats@Yehuda-Katz.local>2009-11-05 15:38:25 -0800
commitb12f194c396b5d279986dd16a3b2caa360e64d19 (patch)
treee93dc34627404a3b69ff4b223e128884941f7d0a /actionpack/lib/action_controller/middleware.rb
parentb0dfd1d19b83f1812317345a68c6bc1ad590be53 (diff)
downloadrails-b12f194c396b5d279986dd16a3b2caa360e64d19.tar.gz
rails-b12f194c396b5d279986dd16a3b2caa360e64d19.tar.bz2
rails-b12f194c396b5d279986dd16a3b2caa360e64d19.zip
Update AC::Middleware to play better with the normal AC::Metal stack. This required stopping to use #call for non-rack-related stuff
Diffstat (limited to 'actionpack/lib/action_controller/middleware.rb')
-rw-r--r--actionpack/lib/action_controller/middleware.rb40
1 files changed, 20 insertions, 20 deletions
diff --git a/actionpack/lib/action_controller/middleware.rb b/actionpack/lib/action_controller/middleware.rb
index fac0ed2645..17275793b7 100644
--- a/actionpack/lib/action_controller/middleware.rb
+++ b/actionpack/lib/action_controller/middleware.rb
@@ -1,34 +1,34 @@
module ActionController
class Middleware < Metal
class ActionMiddleware
- def initialize(controller)
- @controller = controller
+ def initialize(controller, app)
+ @controller, @app = controller, app
end
def call(env)
- controller = @controller.allocate
- controller.send(:initialize)
- controller.app = @app
- controller._call(env)
+ @controller.build(@app).dispatch(:index, env)
end
+ end
+
+ class << self
+ alias build new
- def app=(app)
- @app = app
+ def new(app)
+ ActionMiddleware.new(self, app)
end
end
-
- def self.new(app)
- middleware = ActionMiddleware.new(self)
- middleware.app = app
- middleware
+
+ attr_internal :app
+
+ def process(action)
+ response = super
+ self.status, self.headers, self.response_body = response if response.is_a?(Array)
+ response
end
-
- def _call(env)
- @_env = env
- @_request = ActionDispatch::Request.new(env)
- @_response = ActionDispatch::Response.new
- @_response.request = @_request
- process(:index)
+
+ def initialize(app)
+ super()
+ @_app = app
end
def index