Commits

Magnus Hoff committed 5389c58

Made OneLevelLookup more reusable. Introduced DirectLookup

Comments (0)

Files changed (1)

 }
 
 
-function OneLevelLookup(resourceFactory) {
+function OneLevelLookup(lookupFactory) {
     return {
         lookup: function(reqpath, callback) {
             var split = splitOneLevel(reqpath);
-            if (split[1] === '') {
-                callback(resourceFactory(split[0]));
+            var nestedLookup = lookupFactory(split[0]);
+            nestedLookup.lookup(split[1], callback);
+        }
+    };
+}
+
+
+function DirectLookup(resourceFactory) {
+    return {
+        lookup: function(reqpath, callback) {
+            if (reqpath === '') {
+                resourceFactory(callback);
             } else {
                 callback(null);
             }
 exports.MapLookup = MapLookup;
 exports.FileResource = FileResource;
 exports.FileLookup = FileLookup;
+exports.DirectLookup = DirectLookup;
 exports.OneLevelLookup = OneLevelLookup;
 exports.createServer = createServer;