1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actionpack/lib/action_controller/middleware.rb
Carlhuda 056042eb82 Simplify the action endpoint:
* Remove ActionEndpoint in favor of passing a block to MiddlewareStack
  * Always create a Request; the performance win of RackDelegation is around
    the response; the Request object hit is limited to a single object allocation
  * #dispatch takes a Request
2010-03-08 16:50:00 -08:00

39 lines
No EOL
737 B
Ruby

module ActionController
class Middleware < Metal
class ActionMiddleware
def initialize(controller, app)
@controller, @app = controller, app
end
def call(env)
request = ActionDispatch::Request.new(env)
@controller.build(@app).dispatch(:index, request)
end
end
class << self
alias build new
def new(app)
ActionMiddleware.new(self, app)
end
end
attr_internal :app
def process(action)
response = super
self.status, self.headers, self.response_body = response if response.is_a?(Array)
response
end
def initialize(app)
super()
@_app = app
end
def index
call(env)
end
end
end