aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/middleware.rb
blob: 5fccca0b48b3a6848ccef3c9db802fb07b858afa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
module ActionController
  class Middleware < Metal
    class ActionMiddleware
      def initialize(controller)
        @controller = controller
      end

      def call(env)
        controller = @controller.allocate
        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
      process(:index)
    end
    
    def index
      call(env)
    end
  end
end