2009-08-26 07:18:52 +00:00
|
|
|
module ActionController
|
|
|
|
class Middleware < Metal
|
|
|
|
class ActionMiddleware
|
2009-11-05 23:38:04 +00:00
|
|
|
def initialize(controller, app)
|
|
|
|
@controller, @app = controller, app
|
2009-08-26 07:18:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def call(env)
|
2010-03-09 00:49:47 +00:00
|
|
|
request = ActionDispatch::Request.new(env)
|
|
|
|
@controller.build(@app).dispatch(:index, request)
|
2009-08-26 07:18:52 +00:00
|
|
|
end
|
2009-11-05 23:38:04 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
class << self
|
|
|
|
alias build new
|
2009-08-26 07:18:52 +00:00
|
|
|
|
2009-11-05 23:38:04 +00:00
|
|
|
def new(app)
|
|
|
|
ActionMiddleware.new(self, app)
|
2009-08-26 07:18:52 +00:00
|
|
|
end
|
|
|
|
end
|
2009-11-05 23:38:04 +00:00
|
|
|
|
|
|
|
attr_internal :app
|
|
|
|
|
|
|
|
def process(action)
|
|
|
|
response = super
|
|
|
|
self.status, self.headers, self.response_body = response if response.is_a?(Array)
|
|
|
|
response
|
2009-08-26 07:18:52 +00:00
|
|
|
end
|
2009-11-05 23:38:04 +00:00
|
|
|
|
|
|
|
def initialize(app)
|
|
|
|
super()
|
|
|
|
@_app = app
|
2009-08-26 07:18:52 +00:00
|
|
|
end
|
2010-08-14 05:13:00 +00:00
|
|
|
|
2009-08-26 07:18:52 +00:00
|
|
|
def index
|
|
|
|
call(env)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|