Created
April 29, 2012 17:47
-
-
Save mikebannister/2552208 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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