title: Route based on string in array
body: <p>If I have an array like:</p>
  
  <pre><code>var users = [
      { name: 'joe', info : 'this man's name is joe'},
      { name : 'betty', info : 'this woman's name is betty'}
  ];
  </code></pre>
  
  <p>and route like:</p>
  
  <pre><code>app.get('/test/:person', loadUser, function(req, res) {
     if (!err) {
        res.send(req.user.info);
     }
     else {
        res.redirect('/');
     }
  })
  </code></pre>
  
  <p>how do I set up the <code>loadUser</code> middleware so that if the <code>:person</code> param is equal to one of the names in the array, the page is loaded with its respective info. However, if the <code>:person</code> entered isn't in the array, it simply redirects to another page.</p>
  
  <p>So far what I have is:</p>
  
  <pre><code>function loadUser(req, res, next){
      for(var i= 0; i &lt; users.length; i++) {
      if ( req.params.gg == users[i].id ) {
      req.user = users[i];    
      }
  }       
      next();
  }
  </code></pre>
  
  <p>but I don't know how to add the error part, and the <code>next()</code> part.</p>