简体   繁体   English

反转快递订单路线

[英]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.

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