kopia lustrzana https://github.com/c9/core
mount now allows mounting on the root
rodzic
2025a19647
commit
0e72c85e0f
|
@ -80,8 +80,37 @@ module.exports = function Section(name, description, types) {
|
|||
sections[name].push(section);
|
||||
return section;
|
||||
};
|
||||
|
||||
this.getRoutes = function(){
|
||||
return routes;
|
||||
};
|
||||
|
||||
/**
|
||||
* Mount an existing section on this instance.
|
||||
*
|
||||
* Note that when the first argument is omitted, the section's routes will
|
||||
* be copied onto this instance's routing table.
|
||||
*
|
||||
* @param {string} mountpoint Where to mount this secion, e.g. "/capture/"
|
||||
* @param {Section} section A frontdoor section
|
||||
*/
|
||||
|
||||
this.mount = function(name, section) {
|
||||
if ( arguments.length == 1 ){
|
||||
section = arguments[0];
|
||||
|
||||
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] );
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!sections[name])
|
||||
sections[name] = [];
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue