Last active
August 29, 2015 14:10
-
-
Save codepunkt/f0ac13526a26284249a9 to your computer and use it in GitHub Desktop.
Using prereqs in Hapi 7: Inline functions vs registered server methods.
This file contains 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 server = new (require('hapi')).Server('localhost', 8000); | |
server.method('registered', function(request, reply) { | |
console.log('registered', reply()); | |
}); | |
server.route({ | |
method: 'GET', | |
path: '/', | |
config: { | |
pre: [ | |
{ method: 'registered' }, | |
function(request, reply) { | |
console.log('inline', reply()); | |
} | |
], | |
handler: function(request, reply) { | |
console.log('handler'); | |
reply({ foo: 'bar' }); | |
} | |
} | |
}); | |
server.start(function() { | |
console.log('Server started at: ' + server.info.uri); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment