lib/router/config-router.js
function createLocation(locNode) {
  // TODO: Include ancestor locations in path
  var path = locNode.values.path;

  var terminalLocation = !locNode.getOne('location', false);
  var node = locNode.getOne(/^site_dir|user_dirs|app_dir|user_apps|redirect$/);
  if (!node) {
    // No directives. Only allow this if child locations exist.
    if (terminalLocation)
      throwForNode(locNode, new Error('location directive must contain (or inherit) one of site_dir, user_apps, app_dir, or redirect'));
    else
      return null;
  }

  var settings = map.create();
  var gaid = locNode.getValues('google_analytics_id').gaid;
  if (gaid)
    settings.gaTrackingId = gaid;

  var logAsUser = locNode.getValues('log_as_user').enabled;
  settings.logAsUser = logAsUser;

  // Add the templateDir to the AppSpec, if we have one.
  var templateDir = locNode.getValues('template_dir').dir;
  if (templateDir){
    settings.templateDir = templateDir;
  }

  settings = configRouterUtil.parseApplication(settings, 
      locNode, true);

  switch (node.name) {
    case 'site_dir':
      return createSiteDir(locNode, node, settings);
    case 'app_dir':
      return createAppDir(locNode, node, settings);
    case 'user_apps':
      return createUserApps(locNode, node, settings);
    case 'user_dirs':
      return createUserApps(locNode, node, settings, true);
    case 'redirect':
      return createRedirect(locNode, node, settings);
    default:
      throwForNode(locNode, new Error('Node name ' + node.name + ' was not expected here'));
  }
}
function createLocation(locNode) {
  // TODO: Include ancestor locations in path
  var path = locNode.values.path;

  var terminalLocation = !locNode.getOne('location', false);
  var node = locNode.getOne(/^site_dir|user_dirs|app_dir|user_apps|redirect$/);
  if (!node) {
    // No directives. Only allow this if child locations exist.
    if (terminalLocation)
      throwForNode(locNode, new Error('location directive must contain (or inherit) one of site_dir, user_apps, app_dir, or redirect'));
    else
      return null;
  }

  var settings = map.create();
  var gaid = locNode.getValues('google_analytics_id').gaid;
  if (gaid)
    settings.gaTrackingId = gaid;

  var logAsUser = locNode.getValues('log_as_user').enabled;
  settings.logAsUser = logAsUser;

  // Add the templateDir to the AppSpec, if we have one.
  var templateDir = locNode.getValues('template_dir').dir;
  if (templateDir){
    settings.templateDir = templateDir;
  }

  settings = configRouterUtil.parseApplication(settings, 
      locNode, true);

  switch (node.name) {
    case 'site_dir':
      return createSiteDir(locNode, node, settings);
    case 'app_dir':
      return createAppDir(locNode, node, settings);
    case 'user_apps':
      return createUserApps(locNode, node, settings);
    case 'user_dirs':
      return createUserApps(locNode, node, settings, true);
    case 'redirect':
      return createRedirect(locNode, node, settings);
    default:
      throwForNode(locNode, new Error('Node name ' + node.name + ' was not expected here'));
  }
}
function createLocation ( locNode ) { // TODO: Include ancestor locations in path var path = locNode . values . path ; var terminalLocation = ! locNode . getOne ( 'location' , false ) ; var node = locNode . getOne ( / ^site_dir|user_dirs|app_dir|user_apps|redirect$ / ) ; if ( ! node ) { // No directives. Only allow this if child locations exist. if ( terminalLocation ) throwForNode ( locNode , new Error ( 'location directive must contain (or inherit) one of site_dir, user_apps, app_dir, or redirect' ) ) ; else return null ; } var settings = map . create ( ) ; var gaid = locNode . getValues ( 'google_analytics_id' ) . gaid ; if ( gaid ) settings . gaTrackingId = gaid ; var logAsUser = locNode . getValues ( 'log_as_user' ) . enabled ; settings . logAsUser = logAsUser ; // Add the templateDir to the AppSpec, if we have one. var templateDir = locNode . getValues ( 'template_dir' ) . dir ; if ( templateDir ) { settings . templateDir = templateDir ; } settings = configRouterUtil . parseApplication ( settings , locNode , true ) ; switch ( node . name ) { case 'site_dir' : return createSiteDir ( locNode , node , settings ) ; case 'app_dir' : return createAppDir ( locNode , node , settings ) ; case 'user_apps' : return createUserApps ( locNode , node , settings ) ; case 'user_dirs' : return createUserApps ( locNode , node , settings , true ) ; case 'redirect' : return createRedirect ( locNode , node , settings ) ; default : throwForNode ( locNode , new Error ( 'Node name ' + node . name + ' was not expected here' ) ) ; } }
Validates the location node, and returns the appropriate type of router
it represents.
Validates the location node and returns the appropriate type of router it represents .