refactored

This commit is contained in:
coderaiser 2012-11-15 06:49:53 -05:00
parent 9d626975d1
commit 9c98bd901f
5 changed files with 93 additions and 35 deletions

View file

@ -35,13 +35,14 @@
/* Additional Modules */
exports.appcache = srvrequire('appcache'),
exports.cloudfunc = librequire('cloudfunc'),
exports.auth = srvrequire('auth'),
exports.appcache = srvrequire('appcache'),
exports.cache = srvrequire('cache').Cache,
exports.cloudfunc = librequire('cloudfunc'),
exports.rest = srvrequire('rest'),
exports.socket = srvrequire('socket'),
exports.update = srvrequire('update'),
exports.minify = srvrequire('minify').Minify,
exports.cache = srvrequire('cache').Cache,
exports.zlib = mrequire('zlib');

View file

@ -1,16 +1,63 @@
/* RESTfull module */
var APIURL;
exports.rest = function(req){
var lUrl = req.url,
lMethod = req.method;
/* if lUrl contains api url */
if( lUrl.indexOf(APIURL) === 0 ){
lUrl = lUrl.replace(APIURL, '');
(function(){
"use strict";
var DIR = process.cwd() + '/',
main = require(DIR + 'lib/server/main.js'),
SRVDIR = main.SRVDIR,
Util = main.util,
APIURL = '/api/v1/';
exports.rest = function(req, res, pCallBack){
var lUrl = req.url,
lMethod = req.method;
console.log(lUrl);
/* if lUrl contains api url */
if( Util.isContainStr(lUrl, APIURL) ){
lUrl = lUrl.replace(APIURL, '');
console.log(lUrl);
}
console.log(req.url);
console.log(lMethod);
Util.exec(pCallBack);
/*
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;
}
*/
console.log(req.url);
console.log(req.method);
}
}
};
})();