mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 18:55:26 +00:00
chore(server) controller
This commit is contained in:
parent
05ade24252
commit
7ca17e7bac
1 changed files with 23 additions and 30 deletions
|
|
@ -181,47 +181,40 @@
|
|||
* @param req - запрос клиента (Request)
|
||||
* @param res - ответ сервера (Response)
|
||||
*/
|
||||
function controller(pReq, pRes) {
|
||||
/* Читаем содержимое папки, переданное в url */
|
||||
var lRet, lMin, lCheck, lResult, data,
|
||||
lConfig = main.config,
|
||||
parsedUrl = URL.parse(pReq.url),
|
||||
function controller(req, res) {
|
||||
var check, result,
|
||||
config = main.config,
|
||||
isMin = config.minify,
|
||||
parsedUrl = URL.parse(req.url),
|
||||
query = parsedUrl.search || '',
|
||||
path = main.getPathName(pReq),
|
||||
lName = path;
|
||||
path = main.getPathName(req),
|
||||
name = path;
|
||||
|
||||
if (!expressApp)
|
||||
Util.log(pReq.method + ' ' + path + query);
|
||||
|
||||
data = {
|
||||
name : path,
|
||||
request : pReq,
|
||||
response : pRes
|
||||
};
|
||||
Util.log(req.method + ' ' + path + query);
|
||||
|
||||
/* watching is file changed */
|
||||
if (lConfig.appcache)
|
||||
AppCache.watch(lName);
|
||||
if (config.appcache)
|
||||
AppCache.watch(name);
|
||||
|
||||
lName = Path.join(DIR, lName);
|
||||
lMin = lConfig.minify,
|
||||
lCheck = checkExtension(lName);
|
||||
lResult = lMin && lCheck;
|
||||
name = Path.join(DIR, name);
|
||||
check = checkExtension(name);
|
||||
result = isMin && check;
|
||||
|
||||
Util.ifExec(!lResult,
|
||||
function(pParams) {
|
||||
var lSendName = pParams && pParams.name || lName;
|
||||
Util.ifExec(!result,
|
||||
function(params) {
|
||||
var sendName = params && params.name || name;
|
||||
|
||||
main.sendFile({
|
||||
name : lSendName,
|
||||
cache : lConfig.cache,
|
||||
name : sendName,
|
||||
cache : config.cache,
|
||||
gzip : true,
|
||||
request : pReq,
|
||||
response : pRes
|
||||
request : req,
|
||||
response : res
|
||||
});
|
||||
}, function(pCallBack) {
|
||||
Minify.optimize(lName, {
|
||||
callback : pCallBack,
|
||||
}, function(callback) {
|
||||
Minify.optimize(name, {
|
||||
callback : callback,
|
||||
returnName : true
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue