chore(server) controller

This commit is contained in:
coderaiser 2014-02-10 07:13:02 -05:00
parent 05ade24252
commit 7ca17e7bac

View file

@ -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
});
});