Skip to content

Instantly share code, notes, and snippets.

@rschwabco
Created May 10, 2013 09:03
Show Gist options
  • Save rschwabco/5553327 to your computer and use it in GitHub Desktop.
Save rschwabco/5553327 to your computer and use it in GitHub Desktop.
app.all('/api/*',function(req,res){
try{
var controller = toUpperCase(req.query['controller']),
action = toUpperCase(req.query['action']),
method = (req.query['method']) ? req.query['method'].toLowerCase():'get';
var currentController = require('./routes/'+controller+'.js');
app[method].call(this,'/',currentController[action]);
}catch(e){
res.send(e);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment