Merge pull request +8142 from c9/profile-005-5-page-cache-project-page

Profile 005 5 page cache project page
pull/117/merge
Nikolai Onken 2015-07-08 07:32:04 +02:00
commit 10cd7138ce
1 zmienionych plików z 25 dodań i 17 usunięć

42
node_modules/frontdoor/lib/section.js wygenerowano vendored
Wyświetl plik

@ -96,24 +96,30 @@ module.exports = function Section(name, description, types) {
*/
this.mount = function(name, section) {
if ( arguments.length == 1 ){
var that = this;
if (arguments.length == 1) {
section = arguments[0];
if ( ! ( section instanceof Section ) )
if (!(section instanceof Section))
throw new Error("Single argument to mount must be a Section!");
var addRoutes = section.getRoutes();
Object.keys(addRoutes).forEach(function( method){
routes[method] = [].concat( routes[method], addRoutes[method] );
Object.keys(addRoutes).forEach(function(method) {
var r = addRoutes[method];
r.forEach(function(route) {
route.parent = that;
})
routes[method] = [].concat(routes[method], r);
});
return;
}
if (!sections[name])
sections[name] = [];
section.parent = this;
sections[name].push(section);
};
@ -126,15 +132,17 @@ module.exports = function Section(name, description, types) {
*
* Has a variable number of argumnets: no need to wrap handlers in an array
*/
this.on = function( path, handler ){
var middlewares = Array.prototype.slice.call( arguments, 1 );
this.on = function(path, handler){
var middlewares = Array.prototype.slice.call(arguments, 1);
handler = middlewares.shift();
middlewares.unshift(function(req, res, next){
handler( req, res, next );
middlewares.unshift(function(req, res, next) {
handler(req, res, next);
});
this._route( path, { method: "get" }, middlewares );
this._route(path, {
method: "get"
}, middlewares);
};
this._rootHandler = function(req, res) {
@ -172,7 +180,7 @@ module.exports = function Section(name, description, types) {
var method = req.method.toLowerCase();
if (methods.indexOf(method) == -1)
return next();
var handler = this.match(req, path, method);
if (!handler)
return next();
@ -184,7 +192,7 @@ module.exports = function Section(name, description, types) {
errorHandlers.unshift.apply(errorHandlers, handler.errorHandlers || []);
handler = handler.parent;
}
if (this.globals.length)
middleware.splice.apply( middleware, [1, 0].concat( this.globals ) );