Almost there. Need to store routes as standalone things with state rather than as simple objects, and return them from the createroute method.

This commit is contained in:
Dan Hough
2014-07-10 19:51:14 +01:00
parent 9faf6b3589
commit f267882a3c
4 changed files with 316 additions and 245 deletions

View File

@@ -20,21 +20,20 @@ function FluentInterface(server, o) {
};
function cr() {
debug('##SETUP CALLED FOR', route, 'with parent', parent);
if (!parent) {
if (!parent && !top) {
debug('Fluent setup called for', route.request.url);
lookupHash = server.createRoute(route, lookupHash);
} else {
} else if (parent && top) {
debug('Fluent setup called for', route.request.url, 'with parent', parent.request.url, 'and top', top.request.url);
if (!parent.afterResponse) {
parent.afterResponse = {
endpoints: []
};
}
parent.afterResponse.endpoints.push(route);
if (top) {
server.createRoute(top);
} else {
server.createRoute(parent);
}
server.createRoute(top);
} else {
throw new Error('You cannot specify a parent without a top, dummy!');
}
}