<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>actionpack/lib/action_controller/middleware.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -89,7 +89,6 @@ module AbstractController
       end
 
       process_action(action_name)
-      self
     end
 
   private</diff>
      <filename>actionpack/lib/abstract_controller/base.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,6 +3,7 @@ module ActionController
   autoload :ConditionalGet,       &quot;action_controller/metal/conditional_get&quot;
   autoload :HideActions,          &quot;action_controller/metal/hide_actions&quot;
   autoload :Metal,                &quot;action_controller/metal&quot;
+  autoload :Middleware,           &quot;action_controller/middleware&quot;
   autoload :Layouts,              &quot;action_controller/metal/layouts&quot;
   autoload :RackConvenience,      &quot;action_controller/metal/rack_convenience&quot;
   autoload :Rails2Compatibility,  &quot;action_controller/metal/compatibility&quot;</diff>
      <filename>actionpack/lib/action_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -88,23 +88,6 @@ module ActionController
       end
     end
 
-    class ActionMiddleware
-      def initialize(controller, action)
-        @controller, @action = controller, action
-      end
-
-      def call(env)
-        controller = @controller.new
-        controller.app = @app
-        controller.call(@action, env)
-      end
-
-      def new(app)
-        @app = app
-        self
-      end
-    end
-
     # Return a rack endpoint for the given action. Memoize the endpoint, so
     # multiple calls into MyController.action will return the same object
     # for the same action.
@@ -118,10 +101,5 @@ module ActionController
       @actions ||= {}
       @actions[name.to_s] ||= ActionEndpoint.new(self, name)
     end
-
-    def self.middleware(name)
-      @middlewares ||= {}
-      @middlewares[name.to_s] ||= ActionMiddleware.new(self, name)
-    end
   end
 end</diff>
      <filename>actionpack/lib/action_controller/metal.rb</filename>
    </modified>
    <modified>
      <diff>@@ -19,8 +19,9 @@ module AbstractController
     
     class TestBasic &lt; ActiveSupport::TestCase
       test &quot;dispatching works&quot; do
-        result = Me.new.process(:index)
-        assert_equal &quot;Hello world&quot;, result.response_body
+        controller = Me.new
+        controller.process(:index)
+        assert_equal &quot;Hello world&quot;, controller.response_body
       end
     end
     
@@ -67,29 +68,33 @@ module AbstractController
     end
 
     class TestRenderingController &lt; ActiveSupport::TestCase
+      def setup
+        @controller = Me2.new
+      end
+
       test &quot;rendering templates works&quot; do
-        result = Me2.new.process(:index)
-        assert_equal &quot;Hello from index.erb&quot;, result.response_body
+        @controller.process(:index)
+        assert_equal &quot;Hello from index.erb&quot;, @controller.response_body
       end
       
       test &quot;rendering passes ivars to the view&quot; do
-        result = Me2.new.process(:action_with_ivars)
-        assert_equal &quot;Hello from index_with_ivars.erb&quot;, result.response_body
+        @controller.process(:action_with_ivars)
+        assert_equal &quot;Hello from index_with_ivars.erb&quot;, @controller.response_body
       end
       
       test &quot;rendering with no template name&quot; do
-        result = Me2.new.process(:naked_render)
-        assert_equal &quot;Hello from naked_render.erb&quot;, result.response_body
+        @controller.process(:naked_render)
+        assert_equal &quot;Hello from naked_render.erb&quot;, @controller.response_body
       end
 
       test &quot;rendering to a rack body&quot; do
-        result = Me2.new.process(:rendering_to_body)
-        assert_equal &quot;Hello from naked_render.erb&quot;, result.response_body
+        @controller.process(:rendering_to_body)
+        assert_equal &quot;Hello from naked_render.erb&quot;, @controller.response_body
       end
 
       test &quot;rendering to a string&quot; do
-        result = Me2.new.process(:rendering_to_string)
-        assert_equal &quot;Hello from naked_render.erb&quot;, result.response_body
+        @controller.process(:rendering_to_string)
+        assert_equal &quot;Hello from naked_render.erb&quot;, @controller.response_body
       end
     end
     
@@ -119,14 +124,18 @@ module AbstractController
     end
     
     class TestPrefixedViews &lt; ActiveSupport::TestCase
+      def setup
+        @controller = Me3.new
+      end
+
       test &quot;templates are located inside their 'prefix' folder&quot; do
-        result = Me3.new.process(:index)
-        assert_equal &quot;Hello from me3/index.erb&quot;, result.response_body
+        @controller.process(:index)
+        assert_equal &quot;Hello from me3/index.erb&quot;, @controller.response_body
       end
 
       test &quot;templates included their format&quot; do
-        result = Me3.new.process(:formatted)
-        assert_equal &quot;Hello from me3/formatted.html.erb&quot;, result.response_body
+        @controller.process(:formatted)
+        assert_equal &quot;Hello from me3/formatted.html.erb&quot;, @controller.response_body
       end
     end
     
@@ -168,8 +177,9 @@ module AbstractController
     
     class TestLayouts &lt; ActiveSupport::TestCase
       test &quot;layouts are included&quot; do
-        result = Me4.new.process(:index)
-        assert_equal &quot;Me4 Enter : Hello from me4/index.erb : Exit&quot;, result.response_body
+        controller = Me4.new
+        result = controller.process(:index)
+        assert_equal &quot;Me4 Enter : Hello from me4/index.erb : Exit&quot;, controller.response_body
       end
     end
     
@@ -203,10 +213,11 @@ module AbstractController
     end
     
     class TestRespondToAction &lt; ActiveSupport::TestCase
-      
+
       def assert_dispatch(klass, body = &quot;success&quot;, action = :index)
-        response = klass.new.process(action).response_body
-        assert_equal body, response
+        controller = klass.new
+        controller.process(action)
+        assert_equal body, controller.response_body
       end
       
       test &quot;an arbitrary method is available as an action by default&quot; do</diff>
      <filename>actionpack/test/abstract_controller/abstract_controller_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -19,10 +19,11 @@ module AbstractController
       end
     end
     
-    class TestCallbacks &lt; ActiveSupport::TestCase
+    class TestCallbacks1 &lt; ActiveSupport::TestCase
       test &quot;basic callbacks work&quot; do
-        result = Callback1.new.process(:index)
-        assert_equal &quot;Hello world&quot;, result.response_body
+        controller = Callback1.new
+        result = controller.process(:index)
+        assert_equal &quot;Hello world&quot;, controller.response_body
       end
     end
 
@@ -50,20 +51,24 @@ module AbstractController
       end      
     end
     
-    class TestCallbacks &lt; ActiveSupport::TestCase
+    class TestCallbacks2 &lt; ActiveSupport::TestCase
+      def setup
+        @controller = Callback2.new
+      end
+
       test &quot;before_filter works&quot; do
-        result = Callback2.new.process(:index)
-        assert_equal &quot;Hello world&quot;, result.response_body
+        result = @controller.process(:index)
+        assert_equal &quot;Hello world&quot;, @controller.response_body
       end
       
       test &quot;after_filter works&quot; do
-        result = Callback2.new.process(:index)
-        assert_equal &quot;Goodbye&quot;, result.instance_variable_get(&quot;@second&quot;)
+        @controller.process(:index)
+        assert_equal &quot;Goodbye&quot;, @controller.instance_variable_get(&quot;@second&quot;)
       end
       
       test &quot;around_filter works&quot; do
-        result = Callback2.new.process(:index)
-        assert_equal &quot;FIRSTSECOND&quot;, result.instance_variable_get(&quot;@aroundz&quot;)
+        @controller.process(:index)
+        assert_equal &quot;FIRSTSECOND&quot;, @controller.instance_variable_get(&quot;@aroundz&quot;)
       end
     end
     
@@ -81,15 +86,19 @@ module AbstractController
       end
     end
 
-    class TestCallbacks &lt; ActiveSupport::TestCase
+    class TestCallbacks3 &lt; ActiveSupport::TestCase
+      def setup
+        @controller = Callback3.new
+      end
+      
       test &quot;before_filter works with procs&quot; do
-        result = Callback3.new.process(:index)
-        assert_equal &quot;Hello world&quot;, result.response_body
+        result = @controller.process(:index)
+        assert_equal &quot;Hello world&quot;, @controller.response_body
       end
       
       test &quot;after_filter works with procs&quot; do
-        result = Callback3.new.process(:index)
-        assert_equal &quot;Goodbye&quot;, result.instance_variable_get(&quot;@second&quot;)
+        result = @controller.process(:index)
+        assert_equal &quot;Goodbye&quot;, @controller.instance_variable_get(&quot;@second&quot;)
       end      
     end
     
@@ -116,20 +125,24 @@ module AbstractController
       end
     end
     
-    class TestCallbacks &lt; ActiveSupport::TestCase
+    class TestCallbacksWithConditions &lt; ActiveSupport::TestCase
+      def setup
+        @controller = CallbacksWithConditions.new
+      end
+
       test &quot;when :only is specified, a before filter is triggered on that action&quot; do
-        result = CallbacksWithConditions.new.process(:index)
-        assert_equal &quot;Hello, World&quot;, result.response_body
+        @controller.process(:index)
+        assert_equal &quot;Hello, World&quot;, @controller.response_body
       end
       
       test &quot;when :only is specified, a before filter is not triggered on other actions&quot; do
-        result = CallbacksWithConditions.new.process(:sekrit_data)
-        assert_equal &quot;true&quot;, result.response_body
+        @controller.process(:sekrit_data)
+        assert_equal &quot;true&quot;, @controller.response_body
       end
       
       test &quot;when :except is specified, an after filter is not triggered on that action&quot; do
-        result = CallbacksWithConditions.new.process(:index)
-        assert_nil result.instance_variable_get(&quot;@authenticated&quot;)
+        result = @controller.process(:index)
+        assert_nil @controller.instance_variable_get(&quot;@authenticated&quot;)
       end
     end
     
@@ -156,20 +169,24 @@ module AbstractController
       end      
     end
     
-    class TestCallbacks &lt; ActiveSupport::TestCase
+    class TestCallbacksWithArrayConditions &lt; ActiveSupport::TestCase
+      def setup
+        @controller = CallbacksWithArrayConditions.new
+      end
+
       test &quot;when :only is specified with an array, a before filter is triggered on that action&quot; do
-        result = CallbacksWithArrayConditions.new.process(:index)
-        assert_equal &quot;Hello, World&quot;, result.response_body
+        result = @controller.process(:index)
+        assert_equal &quot;Hello, World&quot;, @controller.response_body
       end
       
       test &quot;when :only is specified with an array, a before filter is not triggered on other actions&quot; do
-        result = CallbacksWithArrayConditions.new.process(:sekrit_data)
-        assert_equal &quot;true&quot;, result.response_body
+        result = @controller.process(:sekrit_data)
+        assert_equal &quot;true&quot;, @controller.response_body
       end
       
       test &quot;when :except is specified with an array, an after filter is not triggered on that action&quot; do
-        result = CallbacksWithArrayConditions.new.process(:index)
-        assert_nil result.instance_variable_get(&quot;@authenticated&quot;)
+        result = @controller.process(:index)
+        assert_nil @controller.instance_variable_get(&quot;@authenticated&quot;)
       end
     end    
     
@@ -181,15 +198,19 @@ module AbstractController
       end
     end
     
-    class TestCallbacks &lt; ActiveSupport::TestCase
+    class TestCallbacksWithChangedConditions &lt; ActiveSupport::TestCase
+      def setup
+        @controller = ChangedConditions.new
+      end
+      
       test &quot;when a callback is modified in a child with :only, it works for the :only action&quot; do
-        result = ChangedConditions.new.process(:index)
-        assert_equal &quot;Hello world&quot;, result.response_body
+        result = @controller.process(:index)
+        assert_equal &quot;Hello world&quot;, @controller.response_body
       end
       
       test &quot;when a callback is modified in a child with :only, it does not work for other actions&quot; do
-        result = ChangedConditions.new.process(:not_index)
-        assert_equal &quot;&quot;, result.response_body        
+        result = @controller.process(:not_index)
+        assert_equal &quot;&quot;, @controller.response_body
       end
     end
     
@@ -207,8 +228,9 @@ module AbstractController
     
     class TestHalting &lt; ActiveSupport::TestCase
       test &quot;when a callback sets the response body, the action should not be invoked&quot; do
-        result = SetsResponseBody.new.process(:index)
-        assert_equal &quot;Success&quot;, result.response_body
+        controller = SetsResponseBody.new
+        controller.process(:index)
+        assert_equal &quot;Success&quot;, controller.response_body
       end
     end
     </diff>
      <filename>actionpack/test/abstract_controller/callbacks_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -34,8 +34,9 @@ module AbstractController
     
     class TestHelpers &lt; ActiveSupport::TestCase
       def test_helpers
-        result = MyHelpers1.new.process(:index)
-        assert_equal &quot;Hello World : Included&quot;, result.response_body
+        controller = MyHelpers1.new
+        controller.process(:index)
+        assert_equal &quot;Hello World : Included&quot;, controller.response_body
       end
     end
     </diff>
      <filename>actionpack/test/abstract_controller/helper_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -143,13 +143,15 @@ module AbstractControllerTests
     
     class TestBase &lt; ActiveSupport::TestCase
       test &quot;when no layout is specified, and no default is available, render without a layout&quot; do
-        result = Blank.new.process(:index)
-        assert_equal &quot;Hello blank!&quot;, result.response_body
+        controller = Blank.new
+        controller.process(:index)
+        assert_equal &quot;Hello blank!&quot;, controller.response_body
       end
       
       test &quot;when layout is specified as a string, render with that layout&quot; do
-        result = WithString.new.process(:index)
-        assert_equal &quot;With String Hello string!&quot;, result.response_body
+        controller = WithString.new
+        controller.process(:index)
+        assert_equal &quot;With String Hello string!&quot;, controller.response_body
       end
       
       test &quot;when layout is specified as a string, but the layout is missing, raise an exception&quot; do
@@ -157,23 +159,27 @@ module AbstractControllerTests
       end
       
       test &quot;when layout is specified as false, do not use a layout&quot; do
-        result = WithFalseLayout.new.process(:index)
-        assert_equal &quot;Hello false!&quot;, result.response_body
+        controller = WithFalseLayout.new
+        controller.process(:index)
+        assert_equal &quot;Hello false!&quot;, controller.response_body
       end
       
       test &quot;when layout is specified as nil, do not use a layout&quot; do
-        result = WithNilLayout.new.process(:index)
-        assert_equal &quot;Hello nil!&quot;, result.response_body
+        controller = WithNilLayout.new
+        controller.process(:index)
+        assert_equal &quot;Hello nil!&quot;, controller.response_body
       end
       
       test &quot;when layout is specified as a symbol, call the requested method and use the layout returned&quot; do
-        result = WithSymbol.new.process(:index)
-        assert_equal &quot;OMGHI2U Hello symbol!&quot;, result.response_body
+        controller = WithSymbol.new
+        controller.process(:index)
+        assert_equal &quot;OMGHI2U Hello symbol!&quot;, controller.response_body
       end
       
       test &quot;when layout is specified as a symbol and the method returns nil, don't use a layout&quot; do
-        result = WithSymbolReturningNil.new.process(:index)
-        assert_equal &quot;Hello nilz!&quot;, result.response_body
+        controller = WithSymbolReturningNil.new
+        controller.process(:index)
+        assert_equal &quot;Hello nilz!&quot;, controller.response_body
       end
       
       test &quot;when the layout is specified as a symbol and the method doesn't exist, raise an exception&quot; do
@@ -185,29 +191,34 @@ module AbstractControllerTests
       end
       
       test &quot;when a child controller does not have a layout, use the parent controller layout&quot; do
-        result = WithStringChild.new.process(:index)
-        assert_equal &quot;With String Hello string!&quot;, result.response_body
+        controller = WithStringChild.new
+        controller.process(:index)
+        assert_equal &quot;With String Hello string!&quot;, controller.response_body
       end
       
       test &quot;when a child controller has specified a layout, use that layout and not the parent controller layout&quot; do
-        result = WithStringOverriddenChild.new.process(:index)
-        assert_equal &quot;With Override Hello string!&quot;, result.response_body
+        controller = WithStringOverriddenChild.new
+        controller.process(:index)
+        assert_equal &quot;With Override Hello string!&quot;, controller.response_body
       end
       
       test &quot;when a child controller has an implied layout, use that layout and not the parent controller layout&quot; do
-        result = WithStringImpliedChild.new.process(:index)
-        assert_equal &quot;With Implied Hello string!&quot;, result.response_body
+        controller = WithStringImpliedChild.new
+        controller.process(:index)
+        assert_equal &quot;With Implied Hello string!&quot;, controller.response_body
       end
       
       test &quot;when a child controller specifies layout nil, do not use the parent layout&quot; do
-        result = WithNilChild.new.process(:index)
-        assert_equal &quot;Hello string!&quot;, result.response_body
+        controller = WithNilChild.new
+        controller.process(:index)
+        assert_equal &quot;Hello string!&quot;, controller.response_body
       end
             
       test &quot;when a grandchild has no layout specified, the child has an implied layout, and the &quot; \
         &quot;parent has specified a layout, use the child controller layout&quot; do
-          result = WithChildOfImplied.new.process(:index)
-          assert_equal &quot;With Implied Hello string!&quot;, result.response_body
+          controller = WithChildOfImplied.new
+          controller.process(:index)
+          assert_equal &quot;With Implied Hello string!&quot;, controller.response_body
       end
       
       test &quot;raises an exception when specifying layout true&quot; do</diff>
      <filename>actionpack/test/abstract_controller/layouts_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,13 +1,12 @@
 require File.join(File.expand_path(File.dirname(__FILE__)), &quot;test_helper&quot;)
 
 module MetalTest
-  class MetalMiddleware &lt; ActionController::Metal
-    def index
+  class MetalMiddleware &lt; ActionController::Middleware
+    def call(env)
       if env[&quot;PATH_INFO&quot;] =~ /authed/
-        self.response = app.call(env)
+        app.call(env)
       else
-        self.response_body = &quot;Not authed!&quot;
-        self.status = 401
+        [401, headers, &quot;Not authed!&quot;]
       end
     end
   end
@@ -21,7 +20,7 @@ module MetalTest
   class TestMiddleware &lt; ActiveSupport::TestCase
     def setup
       @app = Rack::Builder.new do
-        use MetalMiddleware.middleware(:index)
+        use MetalMiddleware
         run Endpoint.new
       end.to_app
     end</diff>
      <filename>actionpack/test/new_base/metal_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>78129b1731a1e6f3b091e996bcf55917d84b5f0e</id>
    </parent>
  </parents>
  <author>
    <name>Yehuda Katz</name>
    <login>wycats</login>
    <email>wycats@gmail.com</email>
  </author>
  <url>http://github.com/rails/rails/commit/9408fcd2e858ae48dd30d9e8d1bb1dcbbfffb840</url>
  <id>9408fcd2e858ae48dd30d9e8d1bb1dcbbfffb840</id>
  <committed-date>2009-08-26T00:18:52-07:00</committed-date>
  <authored-date>2009-08-26T00:18:52-07:00</authored-date>
  <message>Create new ActionController::Middleware class that will work as a normal Rack middleware.

  * This initial implementation is a bit hackish, but it uses a normal middleware API
    so it's future-proof when we improve the internals.</message>
  <tree>c16d280b988d662041fc5834d07078d9da6f2b37</tree>
  <committer>
    <name>Yehuda Katz</name>
    <login>wycats</login>
    <email>wycats@gmail.com</email>
  </committer>
</commit>
