0
當我向http://localhost:4101/endpoint/field
發出請求時,始終會記錄endpoint/:id
。HTTP端點沒有被調用,帶有路徑參數的端點被調用?
爲什麼不是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);
});