Permalink
Browse files

added routes example

  • Loading branch information...
1 parent 423df9b commit ec3e16aecce83b66a54dbc270b910c78715528c8 @tj committed Mar 21, 2012
Showing with 36 additions and 0 deletions.
  1. +19 −0 examples/routes.js
  2. +5 −0 examples/routes.json
  3. +8 −0 examples/routes/photo.js
  4. +4 −0 examples/routes/user.js
View
@@ -0,0 +1,19 @@
+
+var Parser = require('../')
+ , parser = new Parser;
+
+console.log();
+console.log('Before:');
+console.log(parser.read('examples/routes.json'));
+
+parser.use(function(key, val){
+ val = val.split(' ');
+ var path = val.shift();
+ var method = val.shift();
+ return require('./routes/' + path)[method];
+});
+
+console.log();
+console.log('After:');
+console.log(parser.read('examples/routes.json'));
+console.log();
View
@@ -0,0 +1,5 @@
+{
+ "GET /": "photo list",
+ "GET /photo/:id": "photo show",
+ "GET /user/:id": "user show"
+}
View
@@ -0,0 +1,8 @@
+
+exports.list = function(){
+
+};
+
+exports.show = function(){
+
+};
View
@@ -0,0 +1,4 @@
+
+exports.show = function(){
+
+};

0 comments on commit ec3e16a

Please sign in to comment.