aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_controller')
-rw-r--r--actionpack/lib/action_controller/metal.rb22
-rw-r--r--actionpack/lib/action_controller/middleware.rb34
2 files changed, 34 insertions, 22 deletions
diff --git a/actionpack/lib/action_controller/metal.rb b/actionpack/lib/action_controller/metal.rb
index aad9570237..51fbba3661 100644
--- a/actionpack/lib/action_controller/metal.rb
+++ b/actionpack/lib/action_controller/metal.rb
@@ -88,23 +88,6 @@ module ActionController
end
end
- class ActionMiddleware
- def initialize(controller, action)
- @controller, @action = controller, action
- end
-
- def call(env)
- controller = @controller.new
- controller.app = @app
- controller.call(@action, env)
- end
-
- def new(app)
- @app = app
- self
- end
- end
-
# Return a rack endpoint for the given action. Memoize the endpoint, so
# multiple calls into MyController.action will return the same object
# for the same action.
@@ -118,10 +101,5 @@ module ActionController
@actions ||= {}
@actions[name.to_s] ||= ActionEndpoint.new(self, name)
end
-
- def self.middleware(name)
- @middlewares ||= {}
- @middlewares[name.to_s] ||= ActionMiddleware.new(self, name)
- end
end
end
diff --git a/actionpack/lib/action_controller/middleware.rb b/actionpack/lib/action_controller/middleware.rb
new file mode 100644
index 0000000000..5fccca0b48
--- /dev/null
+++ b/actionpack/lib/action_controller/middleware.rb
@@ -0,0 +1,34 @@
+module ActionController
+ class Middleware < Metal
+ class ActionMiddleware
+ def initialize(controller)
+ @controller = controller
+ end
+
+ def call(env)
+ controller = @controller.allocate
+ controller.app = @app
+ controller._call(env)
+ end
+
+ def app=(app)
+ @app = app
+ end
+ end
+
+ def self.new(app)
+ middleware = ActionMiddleware.new(self)
+ middleware.app = app
+ middleware
+ end
+
+ def _call(env)
+ @_env = env
+ process(:index)
+ end
+
+ def index
+ call(env)
+ end
+ end
+end \ No newline at end of file