IpAnswerLogProxy.countOneMinuteAnswer(ip,ep.done('minuteCount'));
IpAnswerLogProxy.countOneHourAnswer(ip, ep.done('hourCount'));
IpAnswerLogProxy.countOneDayAnswer(ip, ep.done('dayCount'));
});
}
/**
* 中间件 要求Ip不在黑名单中
* @param req
* @param res
* @param next
*/
var requireNotInBlackList = function(req, res, next){
var ip = req.ip;
BlackListProxy.isInBlackList(ip, function(err, result){
if(err){
next(err);
}else if(result){
return res.send('您的Ip禁止提交,如有疑问请联系lihui.wang@tulingdao.com');
}else{
next();
}
})
}
exports.isNeedMoveToBlackList = isNeedMoveToBlackList;
exports.requireNotInBlackList = requireNotInBlackList;
在路由中使用:
复制代码 代码如下:
//网页提交接口
router.post('/create', middleware.isNeedMoveToBlackList, paperAnswers.create);
您可能感兴趣的文章: