diff --git a/cloudcmd.js b/cloudcmd.js index 6151b4e0..b1830c86 100644 --- a/cloudcmd.js +++ b/cloudcmd.js @@ -192,8 +192,8 @@ lRet = main.sendFile( pParams ); } else if( Util.isContainStr(p.name, FS) || Util.strCmp( p.name, '/') ){ - if(main.getQuery() === '') - p.request.url += '?html'; + //if( !main.getQuery(p.request) ) + //p.request.url += '?html'; var lName = Minify.allowed.html ? Minify.getName(INDEX) : INDEX; diff --git a/lib/cloudfunc.js b/lib/cloudfunc.js index f7c4ea3d..1089a9df 100644 --- a/lib/cloudfunc.js +++ b/lib/cloudfunc.js @@ -358,17 +358,16 @@ var CloudFunc, exports; /* Сохраняем путь к каталогу верхнего уровня*/ - lFileTable += '
  • '+ - '' + - '' + - '' + - '' + ".." + - '' + - '<dir>' + - '.' + - '' + - '
  • '; + lFileTable += '
  • ' + + '' + + '' + + '' + ".." + + '' + + '<dir>' + + '.' + + '' + + '
  • '; } for(var i = 1, n = files.length; i < n; i++){ diff --git a/lib/server/commander.js b/lib/server/commander.js index 96278d0c..30f2b668 100644 --- a/lib/server/commander.js +++ b/lib/server/commander.js @@ -43,7 +43,7 @@ var p = pParams, lPath = getCleanPath(p.request); - INDEX = p.index; + INDEX = p.index; IndexProcessingFunc = pParams.processing; fs.stat(lPath, function(pError, pStat){ @@ -398,12 +398,11 @@ function noJS(pReq){ var lNoJS, lPath; - if(pReq){ lPath = getPath(pReq); lNoJS = Util.isContainStr(lPath, NO_JS) - || lPath === '/' || main.getQuery(pReq) == 'json'; + || lPath === '/' || main.getQuery(pReq) === 'html'; } return lNoJS; diff --git a/lib/server/rest.js b/lib/server/rest.js index 6957bb31..010e108a 100644 --- a/lib/server/rest.js +++ b/lib/server/rest.js @@ -22,12 +22,12 @@ /** * rest interface - * @pConnectionData {request, responce} + * @pParams {request, responce} */ - exports.api = function(pConnectionData){ - var lRet = false, - lReq = pConnectionData.request, - lRes = pConnectionData.response, + exports.api = function(pParams){ + var lRet, + lReq = pParams.request, + lRes = pParams.response, lUrl = lReq.url, lMethod = lReq.method; @@ -84,18 +84,38 @@ lCmd = Util.removeStr(lCmd, '/'); pParams.command = lCmd; } + if(lCmd === 'fs') + onFS(pParams); + else + switch(lMethod){ + case 'GET': + lResult = onGET(pParams); + break; + + case 'PUT': + lResult = onPUT(pParams); + break; + } + return lResult; + } + + function onFS(pParams){ + var lResult, + lMethod = pParams.method; switch(lMethod){ case 'GET': - lResult = onGET(pParams); + pParams.data = { + mesage: 'fs called' + }; + send(pParams); + lResult = true; break; case 'PUT': lResult = onPUT(pParams); break; } - - return lResult; } /** @@ -171,9 +191,10 @@ * @param pReq * @param pCallBack */ - function getBody(pReq, pCallBack){ + function getBody(pReq, pCallBack){ var lBody = ''; - pReq.on('data', function(chunk) { + + pReq.on('data', function(chunk){ lBody += chunk.toString(); });