Skip to content

Instantly share code, notes, and snippets.

@nlf
Created February 18, 2014 18:12
Show Gist options
  • Save nlf/9076445 to your computer and use it in GitHub Desktop.
Save nlf/9076445 to your computer and use it in GitHub Desktop.
var Hapi = require('hapi');
var Joi = require('joi');
var server = new Hapi.Server('127.0.0.1', 3000);
server.route({
method: 'GET',
path: '/{version}/something',
handler: function (request, reply) {
reply(request.params.version);
},
config: {
validate: {
path: {
version: Joi.string().regex(/v[\d]+/)
}
}
}
});
server.start(function () {
console.log('Server running at:', server.info.uri);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment