title: Dynamic path in express routes
body: <p>I wonder how to using path in express dynamically. For example, i'm using lodash for finding a path in different file with regex method.</p>
  
  <pre><code>routes.js
  </code></pre>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const json = require('./routes.json')
  const _ = require('lodash')
  routes.use(function(req, res, next) {
  
    let str = req.path
    let path = str.split('/')[1]
  
    // [Request] =&gt; /test/123
    console.log(path)
    // [Result] =&gt; test
  
    let test = _.find(json.routes, function(item) {
      return item.path.match(new RegExp('^/' + path + '*'))
    })
    console.log(test)
    //{"path" : "/test/:id", "target" : "localhost:2018", "message" : "This is Test Response" },
  
    routes.get(test.path, function(req, res) {
      res.json("Done")
    })
  })</code></pre>
  </div>
  </div>
  </p>
  
  <p>On above code, i just nested the routes. But there's nothing any response. Is there any ways to do this? This method also i want to use with DB if necessary. Thanks anyway</p>