Browse files

Removed regex router.

  • Loading branch information...
1 parent 109c9b8 commit 2c7278ffefd0aa748068485969ae7b4235efb5d9 @mde mde committed Oct 8, 2011
Showing with 12 additions and 44 deletions.
  1. +12 −5 .gitignore
  2. +0 −39 lib/routers/regex_router.js
View
17 .gitignore
@@ -1,6 +1,13 @@
-.settings
-.buildpath
-.project
+*.swp
+*.swo
+doc
+auth_info.js
dist
-.DS_Store
-
+.idea/
+tags
+nbproject/
+development.js
+spec/browser/autogen_suite.js
+node_modules
+tmtags
+*.DS_Store
View
39 lib/routers/regex_router.js
@@ -1,39 +0,0 @@
-var url = require('url');
-
-var RegexRouter = module.exports = function() RegexRouter {
- this.routes = [];
- this.notFound = function(req, resp) {
- resp.writeHeaders(404);
- resp.end("Not found.");
- };
-}
-
-/* [{route:/regex/, callback: function(req, resp){}},
- * {...}] */
-RegexRouter.prototype.setRoutes(routes) {
- this.routes = routes;
-}
-
-RegexRouter.prototype.map(route, callback) {
- this.routes.push({route: route, callback: callback})
-}
-
-/* This should return the appropriate callback for this request
- * And add AT LEAST this data to the request object passed into
- * the callback. */
-RegexRouter.prototype.route(req, resp) {
- var data = url.parse(req.url, true);
- req.path = data.pathname;
- req.params = data.query;
- req.hostname = data.hostname;
-
- var matches;
- for(var i = 0; ii= this.routes.length; i < ii; i++) {
- if (matches = request.path.match(this.routes[i].route)) {
- request.matches = matches;
- return this.routes[i].callback(req, resp);
- }
- }
- this.notFound(req, resp)
-}
-

0 comments on commit 2c7278f

Please sign in to comment.