Last active
August 29, 2015 14:01
-
-
Save bingeboy/5f3fd37248fbc75d4fcf to your computer and use it in GitHub Desktop.
example of a hapi handler
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 Hapi = require('hapi'); | |
var server = new Hapi.Server(); | |
// Handler in top level | |
var status = function () { | |
this.reply('ok'); | |
}; | |
server.route({ method: 'GET', path: '/status', handler: status }); | |
// Handler in config | |
var user = { | |
cache: { expiresIn: 5000 }, | |
handler: function () { | |
this.reply({ name: 'John' }); | |
} | |
}; | |
server.route({ method: 'GET', path: '/user', config: user }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
see docs http://spumko.github.io/resource/api/#createserver--host----port----options--