【发布时间】:2013-08-20 10:58:52
【问题描述】:
我已将我的 Express.js 项目更改为使用 bower 来安装组件。所有组件都安装在 /components 下(/components/jquery/jquery.js ...等)。
我也创建了自己的路由器,如下所示:
app.get('/', routes.index); // main page
app.get('/p/:name', routes.p); //redirect routes
app.get('/api/contacts', api.contacts); //look at all
app.get('/api/contact/:id', api.contact); //look at one
app.post('/api/contact', api.add); //add contact
app.put('/api/contact/:id', api.edit); //edit&update contact
app.delete('/api/contact/:id', api.delete); //delete contact
/components 没有路由,因此 http://my.project/components/jquery/jquery.js 会返回 Cannot GET /components/jquery/jquyery.js
谁能告诉我为 /components 下的所有组件添加路由的最佳方法是什么?
【问题讨论】: