Created
February 26, 2016 22:46
-
-
Save kevboutin/c9fec3c0b1ffab07bc44 to your computer and use it in GitHub Desktop.
Shows POST and PUT examples in hapi within Node.
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
'use strict'; | |
const Hapi = require('hapi'); | |
const server = new Hapi.Server(); | |
server.connection({ port: 8000 }); | |
// test by using this on command line: | |
// http -v --form POST localhost:8000 fname=Kevin lname=Boutin | |
server.route({ | |
method: ['POST', 'PUT'], | |
path: '/', | |
config: { | |
payload: { | |
output: 'data', | |
parse: false, | |
allow: 'application/json' // comment this line to prevent sending an error back on example | |
} | |
}, | |
handler: function(request, response) { | |
response(request.payload); | |
} | |
}); | |
server.start(() => console.log(`Started at ${server.info.uri}`)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment