我有一个KOA端点。我有一个只能接受数字的quantify参数,我如何在KOA路由器中直接执行它?
.put('/cart/:product/:quantity', async ctx => {
quantity = ctx.params.quantity;
ctx.body = 'my code here';
}发布于 2016-03-17 10:55:37
使用此regexp:
'/cart/:product/:quantity(\\d+)'^匹配仅由数字组成的数量。\d+是正则表达式,但是您必须为路由器添加另一个\,以便将其转换为正确的正则表达式,因为路由是一个字符串。
https://stackoverflow.com/questions/36050453
复制相似问题