这是我的代码:
module.exports = (app) ->
app.use '/v1', isValid, router
router.post '/users/:id/authentications', (req, res, next) ->
obj = _.pick(req.body, 'provider', 'uid', 'oauth_token',
'oauth_token_secret', 'nickname')
unless _.isEmpty(obj)
_.extend(obj, { user_id: req.params.id })
sqs.sendMessage
MessageBody: JSON.stringify obj
QueueUrl: sqsQueueURLs['authentications']
, (err, data) ->
if err
log err
res.status(422)
res.json({ 'message': 'Unprocessable Entity' })
else
res.status(201)
res.json({ 'status': 'OK' })
isValid = (req, res, next) ->
apiKey = req.headers['api-key']
if not apiKey
res.status(401)
res.json { 'message': 'API Key is missing from request' }
else
next()
当我对/users/:id/authentications
端点进行POST时,我的应用程序在引入中间件时返回的HTTP状态代码为404。我可能设置错了,但无法弄清楚如何解决它