title: exit from chain of route specific middleware in express/ nodejs
body: <p>I have a chain of "route specific middleware" for this route, like so:</p>
  
  <pre><code>    var express = require('express');
      var server = express();
      var mw1 = function(req, resp, next) {
          //do stuff
          if (success) {
              next();
          } else {
              req.connection.destroy(); //without calling next()
          }
      };
      var mw2 = function(req, resp, next) {
          //do stuff
          if (success) {
              next();
          } else {
              req.connection.destroy(); //without calling next()
          }
      };
      server.post('/some/path', [mw1, mw2], function(req, resp) {
          //write response
      });
  </code></pre>
  
  <p><code>[mw1, mw2]</code> are the middleware specific to the route <code>/some/path</code>.</p>
  
  <p>This is different from server-wide middleware like this:</p>
  
  <pre><code>    server.use(mw1);
      server.use(mw2);
  </code></pre>
  
  <p>Where it applies to all routes defined.</p>
  
  <p>Now my issue is that I want to exit from the chain. I.e. if <code>success</code> is false in <code>mw1</code>, I do not wish for <code>mw2</code> to be called. If <code>success</code> is false in <code>mw2</code>, I do not without for the route function to be called. Presently, both <code>mw1</code> and <code>mw2</code> appear to be getting called whether or not <code>next()</code> is called - and I do not know why.</p>
  
  <p>How can I go about doing this?</p>