aboutsummaryrefslogblamecommitdiffstats
path: root/actionpack/lib/action_controller/middleware.rb
blob: fac0ed264514a047dff8e633eb0635b2356a9a65 (plain) (tree)
1
2
3
4
5
6
7
8
9








                                         
                                    
















                                             

                                                  
                                    







                     
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