title: Express - Replace middleware on runtime
body: <p>I'm using Express and I would like to replace a middleware <strong>on runtime</strong> (stop running middleware X and start running middleware Y).
  I found an easy way to do it, but no one here is giving it as an option:</p>
  
  <p>Instead of using the first middleware, xMiddleware:</p>
  
  <pre><code>app.use(xMiddleware);
  </code></pre>
  
  <p>I'm wrapping it with another middleware, MyMiddlewareWrap:</p>
  
  <pre><code>MyMiddleware = xMiddleware; 
  
  MyMiddlewareWrap = function (req, res, next) 
  {
      MyMiddleware(req, res, next)
  }
  
  app.use(MyMiddlewareWrap);
  </code></pre>
  
  <p>Then, when I want to stop running xMiddleware and start running yMiddleware, I'm assigning yMiddleware to MyMiddleware:</p>
  
  <pre><code>MyMiddleware = yMiddleware; 
  </code></pre>
  
  <p>As a result, xMiddleware doesn't run anymore and yMiddleware is running instead.
  Does anyone see a problem with it? Is it a good solution?</p>