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


                          

                                           


                   
                                                     
         



                     
 

                                       

         






                                                                                       
       



                       






               
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