【发布时间】:2016-09-13 11:44:57
【问题描述】:
当我向http://localhost:4101/endpoint/field 发出请求时,endpoint/:id 始终会被记录。
为什么没有endpoint/field 登录?
我知道:id 是一个路径参数,可以是任何东西,但我明确表示field 应该以不同方式处理。
'use strict';
var express = require('express');
var app = express();
var PORT = 4101;
app.route('/endpoint/:id')
.get(function(req, res) {
console.log('endpoint/:id');
});
app.route('/endpoint/field')
.get(function(req, res) {
console.log('endpoint/field');
});
app.listen(PORT, function(err) {
if (err) {
console.log('err on startup ' + err);
return;
}
console.log('Server listening on port ' + PORT);
});
【问题讨论】: