[英]Inversify Express order routes
I'm using inversify-express-utils
and I'm looking for a way to set an order for how my endpoints are matched.我正在使用
inversify-express-utils
并且我正在寻找一种方法来设置我的端点匹配方式的顺序。
eg... using express.例如...使用快递。 The router could have
路由器可能有
router.get('/users/me')
router.get('/users/:userId')
and the users/me
endpoint would resolve successfully.并且
users/me
端点将成功解决。
But using inversify
, I have endpoints and controllers like so (detail left out just to show decorators)但是使用
inversify
,我有这样的端点和控制器(省略细节只是为了展示装饰器)
@controller('/users')
@httpGet('/:userId')
@controller('/users/me')
@httpGet('/')
It seems like the users/me
controller is being registered later, even though I import it earlier, and so it's calling users/:userId
with the userId
param set to me instead.似乎
users/me
controller 稍后注册,即使我之前导入它,所以它调用users/:userId
并将userId
参数设置为我。
Is there a way to sort this?有没有办法对此进行排序?
with regex conditions带有正则表达式条件
router.get('users/:userId(^me$)', (req, res) => {
res.send('it is me')
});
router.get('users/:userId)', (req, res) => {
res.send('it is not me')
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.