Global - nokitjs/nokit GitHub Wiki
Global 和 Filter 很像,但一个应用只能有一个 Global 或没有 Gloabl,也可以认为 Gloabl 是一个特殊的 Filter,它比 Filter 多了两个事件 onStart
、onStop
/**
* 全局应用程序类
**/
var Global = function () { };
/**
* 在 server 启动时
**/
Global.prototype.onStart = function (server, done) {
done();
};
/**
* 在 server 停止时
**/
Global.prototype.onStop = function (server, done) {
done();
};
/**
* 在请求发生异常时
**/
Global.prototype.onError = function (context, done) {
done();
};
/**
* 在请求到达时
**/
Global.prototype.onRequest = function (context, done) {
done();
};
/**
* 在收到请求数据时
**/
Global.prototype.onReceived = function (context, done) {
done();
};
/**
* 在发送响应时
**/
Global.prototype.onResponse = function (context, done) {
done();
};
/**
* export
**/
module.exports = Global;