I'm trying to have one route cover everything under /foo
including /foo
itself. I've tried using /foo*
which work for everything except it doesn't match /foo
. Observe:
var express = require("express"),
app = express.createServer();
app.get("/foo*", function(req, res, next){
res.write("Foo*
");
next();
});
app.get("/foo", function(req, res){
res.end("Foo
");
});
app.get("/foo/bar", function(req, res){
res.end("Foo Bar
");
});
app.listen(3000);
Outputs:
$ curl localhost:3000/foo
Foo
$ curl localhost:3000/foo/bar
Foo*
Foo Bar
What are my options? The best I've come up with is to route /fo*
which of course isn't very optimal as it would match way too much.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…