简体   繁体   English

在sammy.js中注册多条路线

[英]registering multiple routes in sammy.js

I want to register multiple routes for one callback like below. 我想为一个回调注册多个路由,如下所示。 I sperated them with "," character just for show what i mean. 我用“,”字符拼写它们只是为了表明我的意思。 Is it possible to do such a thing ? 有可能做这样的事吗?

this.get('/Posts/MostVoteds, /Posts/Mostpopular, /Posts/blabla', function (ctx) {

        });

As soon as paths could be defined both as strings and regular expressions you could try merging paths mentioned in a single regular expression, ie 只要路径可以定义为字符串和正则表达式,您就可以尝试合并单个正则表达式中提到的路径,即

this.get(/^\/Posts\/(MostVoteds|Mostpopular|blabla)/, function (ctx) {
    // some code here
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM