mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
38 lines
No EOL
682 B
Ruby
38 lines
No EOL
682 B
Ruby
module ActionController
|
|
class Middleware < Metal
|
|
class ActionMiddleware
|
|
def initialize(controller, app)
|
|
@controller, @app = controller, app
|
|
end
|
|
|
|
def call(env)
|
|
@controller.build(@app).dispatch(:index, env)
|
|
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 |