title: Calling a function inside route handler vs using a middleware
body: <p>I am trying to understand if there is any difference. I'll try to explain it with an example from express docs: <a href="https://expressjs.com/en/guide/using-middleware.html" rel="nofollow noreferrer">https://expressjs.com/en/guide/using-middleware.html</a></p>
  <pre><code>function logOriginalUrl (req, res, next) {
    console.log('Request URL:', req.originalUrl)
    next()
  }
  
  function logMethod (req, res, next) {
    console.log('Request Type:', req.method)
    next()
  }
  
  const logStuff = [logOriginalUrl, logMethod]
  app.get('/user/:id', logStuff, (req, res, next) =&gt; {
    res.send('User Info')
  })
  </code></pre>
  <p>logOriginalUrl and logMethod are middlewares in this example. What would happen if I write it like:</p>
  <pre><code>function logOriginalUrl() {
    console.log('Request URL:', req.originalUrl);
  }
  
  function logMethod() {
    console.log('Request Type:', req.method);
  }
  
  app.get('/user/:id', (req, res, next) =&gt; {
    logOriginalUrl();
    logMethod();
    res.send('User Info')
  })
  </code></pre>
  <p>Is there any difference between these two? This is a very simple example but it can be  applied for any other example where you have to manipulate req or do anything else.</p>
  <p>What is the difference between a middleware and calling + awaiting a function inside route handler?</p>
  <p>Theoretically, anything I can do as middleware, I feel like I can achieve exact same thing by awaiting same function in route handler function. So, what do I miss?</p>