nl_tokens: Called from GhostTrain#send makes the request via the routing service . Takes a verb url optional params and a callback that passes in an err object and the data response from the router .
pl_tokens: function send ( ghosttrain , verb , url , params , callback ) { var req , res ; verb = verb . toLowerCase ( ) ; // Allow `params` to be optional if ( typeof arguments [ 3 ] === 'function' ) { callback = params ; params = { } ; } // Clones if `params` is an object var options = clone ( params ) ; // Set up headers if ( ! options . headers ) options . headers = { } ; if ( options . contentType ) options . headers [ 'Content-Type' ] = options . contentType ; // We take out all the host information from the URL so we can match it var parsedURL = parseURL ( url , true ) ; var route = findRoute ( ghosttrain , verb , parsedURL ) ; reqDebug ( ghosttrain , 'REQ' , verb , url ) ; function execute ( ) { if ( route ) { req = new Request ( ghosttrain , route , parsedURL , options ) ; res = new Response ( ghosttrain , success ) ; route . callback ( req , res ) ; } else { if ( callback ) callback ( '404: No route found.' , null , null ) ; } } // Ensure the processing is asynchronous setTimeout ( execute , options . delay || ghosttrain . get ( 'delay' ) || 0 ) ; function success ( data ) { var response = render ( req , res , <mask> ) ; reqDebug ( ghosttrain , 'RES' , verb , url , response ) ; if ( ! callback ) return ; // TODO error handling from router callback ( null , response , data ) ; } }