mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-24 03:05:41 +00:00
61 lines
1.9 KiB
JavaScript
61 lines
1.9 KiB
JavaScript
/* RESTfull module */
|
|
|
|
(function(){
|
|
"use strict";
|
|
|
|
var DIR = process.cwd() + '/',
|
|
main = require(DIR + 'lib/server/main'),
|
|
Util = main.util,
|
|
|
|
APIURL = '/api/v1/';
|
|
|
|
/**
|
|
* rest interface
|
|
* @pConnectionData {request, responce}
|
|
*/
|
|
exports.rest = function(pConnectionData){
|
|
var lReq = pConnectionData.request,
|
|
lRes = pConnectionData.response,
|
|
lUrl = lReq.url,
|
|
lMethod = lReq.method;
|
|
|
|
console.log(lUrl);
|
|
console.log(lMethod);
|
|
|
|
if( Util.isContainStr(lUrl, APIURL) )
|
|
console.log('api !!!!!!!!!!!! ');
|
|
/*
|
|
switch(req.method){
|
|
case 'GET':
|
|
switch(lCommand){
|
|
case 'count':
|
|
lResult = {
|
|
count : Users.length,
|
|
};
|
|
break;
|
|
|
|
case 'list':
|
|
lResult = Users;
|
|
break;
|
|
}
|
|
break;
|
|
|
|
case 'PUT':
|
|
if( lCommand.indexOf('register') === 0 ){
|
|
lResult = {
|
|
registered : true,
|
|
name : req.body.name,
|
|
server_time : Util.getTime(),
|
|
client_time : req.body.time
|
|
};
|
|
Users.push(req.body.name);
|
|
|
|
console.log(lResult);
|
|
console.log(req.connection.remoteAddress);
|
|
}
|
|
break;
|
|
}
|
|
*/
|
|
|
|
};
|
|
})();
|