function populateSingleRoute(request){  
    var method = request.method, 
    mountPath = request.mountPath;
    
    if (!mountPath){
      console.warn('WARNING: Request found with no mount path - probably from a previous version of REST client. Offending request: ');
      console.log(request);
      return;
    }
    
    router[method.toLowerCase()](mountPath, function(req, res){
      // Handle the mounted route using our requester library
      return requester(request, false, function(err, requestResult){
        if (err){
          return res.status(500).json(err);
        }
        var status = requestResult.response.statusCode || 500;
        
        if (!requestResult || !requestResult.response || !requestResult.response.body){
          return res.status(status).end();
        }
        
        var responseBody = requestResult.response.mapped || requestResult.response.body;
        if (typeof responseBody !== 'object'){
          return res.status(status).end(responseBody);
        }
        return res.status(status).json(responseBody);
      });
    });
  }
// Adds a single route into the router from a request definition in the DB
Adds a single route into the router from a request definition in the DB
Adds a single route into the router from a request definition in the DB
function populateSingleRoute(request){  
    var method = request.method, 
    mountPath = request.mountPath;
    if (!mountPath){
      console.warn('WARNING: Request found with no mount path - probably from a previous version of REST client. Offending request: ');
      console.log(request);
      return;
    }
    router[method.toLowerCase()](mountPath, function(req, res){
      return requester(request, false, function(err, requestResult){
        if (err){
          return res.status(500).json(err);
        }
        var status = requestResult.response.statusCode || 500;
        if (!requestResult || !requestResult.response || !requestResult.response.body){
          return res.status(status).end();
        }
        var responseBody = requestResult.response.mapped || requestResult.response.body;
        if (typeof responseBody !== 'object'){
          return res.status(status).end(responseBody);
        }
        return res.status(status).json(responseBody);
      });
    });
  }
function populateSingleRoute ( request ) { var method = request . method , mountPath = request . mountPath ; if ( ! mountPath ) { console . warn ( 'WARNING: Request found with no mount path - probably from a previous version of REST client. Offending request: ' ) ; console . log ( request ) ; return ; } router [ method . toLowerCase ( ) ] ( mountPath , function ( req , res ) { return requester ( request , false , function ( err , requestResult ) { if ( err ) { return res . status ( 500 ) . json ( err ) ; } var status = requestResult . response . statusCode || 500 ; if ( ! requestResult || ! requestResult . response || ! requestResult . response . body ) { return res . status ( status ) . end ( ) ; } var responseBody = requestResult . response . mapped || requestResult . response . body ; if ( typeof responseBody !== 'object' ) { return res . status ( status ) . end ( responseBody ) ; } return res . status ( status ) . json ( responseBody ) ; } ) ; } ) ; }
Adds a single route into the router from a request definition in the DB
Adds a single route into the router from a request definition in the DB
// Handle the mounted route using our requester library