aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/middleware.rb
diff options
context:
space:
mode:
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