Skip to content

Instantly share code, notes, and snippets.

@ETiV
Last active December 15, 2015 13:19
Show Gist options
  • Save ETiV/5266380 to your computer and use it in GitHub Desktop.
Save ETiV/5266380 to your computer and use it in GitHub Desktop.
A template of filter for pomelo framework.
/**
* Filter
*/
module.exports = function() {
return new Filter();
};
var Filter = function() {
};
/**
* before filter
* Requests go though here first. This is for a preparation for anything you want to do.
* @param {Object} msg Requested content from a client
* @param {Object} session Current session of a player
* @param {Function} next The next callback function. |function next(){}|
*/
Filter.prototype.before = function(msg, session, next){
};
/**
* after filter
* Requests go though here at last, even an error occurred.
* You can also do anything you want, except changing the content of the response body.
* Because they've been already sent to the client.
* @param {Object} err The Error object
* @param {Object} msg Requested content from a client
* @param {Object} session Current session of a player
* @param {Object} resp Response content from the server
* @param {Function} next The next callback function. |function next(err, resp){}|
*/
Filter.prototype.after = function(err, msg, session, resp, next) {
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment