mirror of https://gitee.com/bigwinds/arangodb
Frank: Add the middleware to the routing info
This commit is contained in:
parent
c926955541
commit
28c24b1d0c
|
@ -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
|
||||
|
|
|
@ -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, "/*");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue