aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/middleware.rb
diff options
context:
space:
mode:
authorYehuda Katz <wycats@gmail.com>2009-08-26 00:18:52 -0700
committerYehuda Katz <wycats@gmail.com>2009-08-26 00:18:52 -0700
commit9408fcd2e858ae48dd30d9e8d1bb1dcbbfffb840 (patch)
treec16d280b988d662041fc5834d07078d9da6f2b37 /actionpack/lib/action_controller/middleware.rb
parent78129b1731a1e6f3b091e996bcf55917d84b5f0e (diff)
downloadrails-9408fcd2e858ae48dd30d9e8d1bb1dcbbfffb840.tar.gz
rails-9408fcd2e858ae48dd30d9e8d1bb1dcbbfffb840.tar.bz2
rails-9408fcd2e858ae48dd30d9e8d1bb1dcbbfffb840.zip
Create new ActionController::Middleware class that will work as a normal Rack middleware.
* This initial implementation is a bit hackish, but it uses a normal middleware API so it's future-proof when we improve the internals.
Diffstat (limited to 'actionpack/lib/action_controller/middleware.rb')
-rw-r--r--actionpack/lib/action_controller/middleware.rb34
1 files changed, 34 insertions, 0 deletions
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