Created
January 5, 2014 21:11
-
-
Save kuryaki/8273927 to your computer and use it in GitHub Desktop.
Dynamic Router with express ??
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
| 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