I have the code below, and the path
is really confusing. The api guide of restify do not explain much.
const restify = require('restify');
const app = restify.createServer();
app.get(/\/path\/.*/, function(req,res,next){
console.log('regexp');
return next(); // suppose to pass control to next handler, but nothing happended.
})
// it seems that '/path/:name' has the same meaning of /\/path\/.*/. Did I miss something?
app.get('/path/:name', function(req,res,next){
console.log('colon')
return next();// still not pass control to next handler
})
// those two works as expected.
app.get('/path/first', function(req,res,next){
res.end('first');
})
app.get('/path/second', function(req,res,next){
res.end('second');
})
app.listen(80, function () {
console.log('Server is running');
});
so can someone explain to me the exact meaning of those path? and how can i make the next()
work?