From c8019d2976a11c412398b9ab87f31e6d33b72371 Mon Sep 17 00:00:00 2001 From: hefangshi <hefangshi@baidu.com> Date: Thu, 25 Aug 2016 15:50:40 +0800 Subject: [PATCH] load reqlimit bydefault --- plugins/http/index.js | 1 + plugins/reqlimit/index.js | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/http/index.js b/plugins/http/index.js index be292f5..1ef2580 100644 --- a/plugins/http/index.js +++ b/plugins/http/index.js @@ -60,6 +60,7 @@ function core(app, conf){ var defaultConf = { middleware: [ + 'reqlimit', 'favicon', 'compression', 'static', diff --git a/plugins/reqlimit/index.js b/plugins/reqlimit/index.js index 57272bc..5249c5a 100644 --- a/plugins/reqlimit/index.js +++ b/plugins/reqlimit/index.js @@ -17,7 +17,7 @@ function initEventLoop(conf) { return eventloop; } -module.exports.reqlimit = function (app, conf) { +module.exports.reqlimit = ['log', function (app, conf) { var shouldLimit = conf.shouldLimit; var onLimit = conf.onLimit; var eventloop; @@ -47,13 +47,13 @@ module.exports.reqlimit = function (app, conf) { }); }); }; -}; +}]; module.exports.reqlimit.defaultConf = { eventLoop: { interval: 300 }, - maxDelay: 300, + maxDelay: 1000, shouldLimit: function (info, conf, cb) { if (info.delay > conf.maxDelay) { return cb && cb(null, true);