Skip to content

Instantly share code, notes, and snippets.

@kuryaki
Created January 5, 2014 21:11
Show Gist options
  • Select an option

  • Save kuryaki/8273927 to your computer and use it in GitHub Desktop.

Select an option

Save kuryaki/8273927 to your computer and use it in GitHub Desktop.
Dynamic Router with express ??
var http = require('http')
, express = require('express');
var app = express();
var controllers = [
{
method: 'get',
path: '/',
exec: function(req, res) {
res.send('hola mundo');
}
},
{
method: 'get',
path: '/hola',
exec: function(req, res) {
res.send('mundo');
}
}
]
controllers.forEach(function(controller) {
app[controller.method](controller.path, controller.exec)
});
http.createServer(app).listen(3000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment