1
0
Fork 0

Frank: Add the middleware to the routing info

This commit is contained in:
Lucas Dohmen 2013-03-06 17:35:19 +01:00
parent c926955541
commit 28c24b1d0c
2 changed files with 20 additions and 1 deletions

View File

@ -60,7 +60,7 @@ internal.createUrlObject = function (url, constraint, method) {
// * **The Template Collection:** More information in the template section
Frank = function (options) {
'use strict';
var urlPrefix, templateCollection;
var urlPrefix, templateCollection, myMiddleware;
options = options || {};
@ -78,7 +78,17 @@ Frank = function (options) {
if (_.isString(templateCollection)) {
this.routingInfo.templateCollection = db._collection(templateCollection) ||
db._create(templateCollection);
myMiddleware = new BaseMiddleware(templateCollection);
} else {
myMiddleware = new BaseMiddleware();
}
this.routingInfo.middleware = [
{
url: {match: "/*"},
action: {callback: myMiddleware}
}
];
};
// ## The functions on a created Frank

View File

@ -50,6 +50,15 @@ function CreateFrankSpec () {
assertEqual(routingInfo.routes.length, 0);
assertNotNull(templateCollection);
assertEqual(routingInfo.templateCollection, templateCollection);
},
testAdditionOfBaseMiddlewareInRoutingInfo: function () {
var app = new Frank(),
routingInfo = app.routingInfo,
hopefully_base = routingInfo.middleware[0];
assertEqual(routingInfo.middleware.length, 1);
assertEqual(hopefully_base.url.match, "/*");
}
};
}