title: How can I create an Express route that handles URLs that look like this?
body: <pre><code>app.get('/:service[SOMETHING GOES HERE]', function(req, res, next){
      console.log('Service is:', req.params.service);
  });
  </code></pre>
  
  <p>This needs to catch URLs that can look like any one of:</p>
  
  <pre><code>/foo
  /foo/bar
  /foo/bar/baz
  </code></pre>
  
  <p>The call back isn't concerned with anything that comes after foo, but ideally should be able to access foo as a parameter called <code>service</code> without having to manually parse the path.</p>
  
  <p>I've been using <a href="http://forbeslindesay.github.io/express-route-tester/" rel="nofollow">this</a> to test and still haven't found anything that does exactly that. Closest so far is <code>/:service*</code>.</p>
  
  <p>Edit: No it's not a duplicate of the one where the answer is <code>/:service/*</code> because that doesn't cover <code>/foo</code>.</p>