如何知道路由器的快速安装path?

我在Web应用程序上使用快速路由器 。 我以通常的方式添加路由器:

app.use(router, '/myroutehere/'); 

每个路由器的处理程序都不知道它们在哪里“安装”(不同的文件,不同的问题等)。 直到现在,这一直工作正常,我需要为其中一个路由器创build一个ToC(并且内容是dynamic生成的)。 我正在使用url.resolve来处理相对path,但我遗漏了url的初始部分(否则链接将parsing为/而不是/myrouter/ )。

有没有办法知道路由器的安装path,而不是在不同的地方硬编码?

 router.get('/', function(req, res){ // Need to know the mount path here or a way to resolve relative links // to the mount path and make them absolute to the app }); 

那么“router.mountpath”呢?

http://expressjs.com/api.html#app.mountpath

UPD。 好的,你需要: <req.route.path>, <req.baseUrl>, <req.originalUrl>