lib/camp.js
function routeUnit (server) {
  var regexes = [];
  var callbacks = [];

  function route (paths, literalCall) {
    regexes.push(RegExp(paths));
    callbacks.push(literalCall);
  }

  server.route = route;

  return function routeLayer (req, res, next) {
    var matched = null;
    var cbindex = -1;
    for (var i = 0; i < regexes.length; i++) {
      matched = req.path.match (regexes[i]);
      if (matched !== null) { cbindex = i; break; }
    }
    if (cbindex >= 0) {
      catchpath(req, res, matched, callbacks[cbindex], server.templateReader);
    } else {
      next();
    }
  };
}
function routeUnit (server) {
  var regexes = [];
  var callbacks = [];

  function route (paths, literalCall) {
    regexes.push(RegExp(paths));
    callbacks.push(literalCall);
  }

  server.route = route;

  return function routeLayer (req, res, next) {
    var matched = null;
    var cbindex = -1;
    for (var i = 0; i < regexes.length; i++) {
      matched = req.path.match (regexes[i]);
      if (matched !== null) { cbindex = i; break; }
    }
    if (cbindex >= 0) {
      catchpath(req, res, matched, callbacks[cbindex], server.templateReader);
    } else {
      next();
    }
  };
}
function routeUnit ( server ) { var regexes = [ ] ; var callbacks = [ ] ; function route ( paths , literalCall ) { regexes . push ( RegExp ( paths ) ) ; callbacks . push ( literalCall ) ; } server . route = route ; return function routeLayer ( req , res , next ) { var matched = null ; var cbindex = - 1 ; for ( var i = 0 ; i < regexes . length ; i ++ ) { matched = req . path . match ( regexes [ i ] ) ; if ( matched !== null ) { cbindex = i ; break ; } } if ( cbindex >= 0 ) { catchpath ( req , res , matched , callbacks [ cbindex ] , server . templateReader ) ; } else { next ( ) ; } } ; }
Template unit.
Template unit .