Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added routes example

  • Loading branch information...
commit ec3e16aecce83b66a54dbc270b910c78715528c8 1 parent 423df9b
@tj authored
View
19 examples/routes.js
@@ -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
5 examples/routes.json
@@ -0,0 +1,5 @@
+{
+ "GET /": "photo list",
+ "GET /photo/:id": "photo show",
+ "GET /user/:id": "user show"
+}
View
8 examples/routes/photo.js
@@ -0,0 +1,8 @@
+
+exports.list = function(){
+
+};
+
+exports.show = function(){
+
+};
View
4 examples/routes/user.js
@@ -0,0 +1,4 @@
+
+exports.show = function(){
+
+};
Please sign in to comment.
Something went wrong with that request. Please try again.