【发布时间】:2014-06-12 15:06:26
【问题描述】:
我正在尝试将多个通配符 url 路由到 express 中的同一函数。我想我需要某种正则表达式,但我不知道该怎么做。
我想做这样的事情:
app.route(['scripts/*', 'styles/*', 'images/*']).get(handler);
【问题讨论】:
我正在尝试将多个通配符 url 路由到 express 中的同一函数。我想我需要某种正则表达式,但我不知道该怎么做。
我想做这样的事情:
app.route(['scripts/*', 'styles/*', 'images/*']).get(handler);
【问题讨论】:
找到了一种方法:
app.route('/:url(api|components|scripts|styles|bower_components|images)/*')
.get(errors[404]);
【讨论】: