nl_tokens: PrivateFunction : matchRoute This function takes an HTTP method and a URL . It tries to match any API route contained in apiRoutes . If a route is found the routes regex is used to extract any parameters from the URL . These parameters are contained in the params argument afterwards .
pl_tokens: function matchRoute ( method , url , apiRoutes , params ) { debug ( 'matching route method %s with url %s' , method , url ) ; var routes = apiRoutes [ method ] , matchedRoute ; for ( var routeUrl in routes ) { var route = routes [ routeUrl ] , keys = route . keys , match = route . regexp . exec ( <mask> ) ; if ( match ) { matchedRoute = route ; extractParams ( match , keys , params ) ; break ; } } debug ( 'matched route `%j`' , matchedRoute ) ; return matchedRoute ; }