0
我想將中間件應用於路由,而不管請求的類型如何。目前,我有:申請中間件在Express中路由
router.route('/campaigns')
.get(restrictTo('advertiser'), restrictTo('admin'), queries.getCampaigns)
.post(restrictTo('advertiser'), restrictTo('admin'), queries.createCampaign);
而且我想是這樣的:
router.route('/campaigns', restrictTo('advertiser'), restrictTo('admin'))
.get(queries.getCampaigns)
.post(queries.createCampaign);
但這似乎並沒有工作。
不工作.. – ocram
應該是'。所有()','。用() '只適用於整個路由器,而不適用於單一路由。 – robertklep