mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
38 lines
No EOL
767 B
Ruby
38 lines
No EOL
767 B
Ruby
module ActionController
|
|
class Middleware < Metal
|
|
class ActionMiddleware
|
|
def initialize(controller)
|
|
@controller = controller
|
|
end
|
|
|
|
def call(env)
|
|
controller = @controller.allocate
|
|
controller.send(:initialize)
|
|
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
|
|
@_request = ActionDispatch::Request.new(env)
|
|
@_response = ActionDispatch::Response.new
|
|
@_response.request = @_request
|
|
process(:index)
|
|
end
|
|
|
|
def index
|
|
call(env)
|
|
end
|
|
end
|
|
end |