2009-08-26 03:18:52 -04:00
|
|
|
module ActionController
|
|
|
|
class Middleware < Metal
|
|
|
|
class ActionMiddleware
|
|
|
|
def initialize(controller)
|
|
|
|
@controller = controller
|
|
|
|
end
|
|
|
|
|
|
|
|
def call(env)
|
|
|
|
controller = @controller.allocate
|
2009-08-26 14:13:02 -04:00
|
|
|
controller.send(:initialize)
|
2009-08-26 03:18:52 -04:00
|
|
|
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
|
2009-08-26 14:13:02 -04:00
|
|
|
@_request = ActionDispatch::Request.new(env)
|
|
|
|
@_response = ActionDispatch::Response.new
|
2009-08-26 23:51:54 -04:00
|
|
|
@_response.request = @_request
|
2009-08-26 03:18:52 -04:00
|
|
|
process(:index)
|
|
|
|
end
|
|
|
|
|
|
|
|
def index
|
|
|
|
call(env)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|