Skip to content

Instantly share code, notes, and snippets.

@mikebannister
Created April 29, 2012 17:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mikebannister/2552208 to your computer and use it in GitHub Desktop.
Save mikebannister/2552208 to your computer and use it in GitHub Desktop.
var helloMiddleware = function(name) {
return 'Hello ' + + '!';
};
var hiMiddleware = function(name) {
return 'Hi ' + + '!';
};
var counts = {};
var countMiddleware = function(name) {
if (!_.isDefined(counts[name])) {
counts[name] = 0;
} else {
counts[name]++;
}
};
Meteor.methods({
mikeName: function() {
return "Mike";
},
jonathanName: function() {
return "Jonathan";
};
});
# Add middleware to an individual method
Meteor.methods.mikeName.addMiddleware(helloMiddleware);
Meteor.methods.jonathanName.addMiddleware(helloMiddleware);
# Or to add middleware to all methods
#
# Meteor.methods.addMiddleware(countMiddleware);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment