mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 18:55:26 +00:00
refactor(server) join
This commit is contained in:
parent
3211117bdf
commit
bbfff3c704
1 changed files with 16 additions and 13 deletions
|
|
@ -184,7 +184,9 @@
|
|||
lRet = Util.exec(Route, data);
|
||||
|
||||
if (!lRet)
|
||||
lRet = join(data);
|
||||
lRet = join(pReq, pRes, function(error) {
|
||||
main.sendError(data, error);
|
||||
});
|
||||
|
||||
if (!lRet) {
|
||||
lName = data.name;
|
||||
|
|
@ -226,27 +228,29 @@
|
|||
};
|
||||
}
|
||||
|
||||
function join(params) {
|
||||
function join(request, response, callback) {
|
||||
var names, i, n, name, minName, stream, check,
|
||||
funcs = [],
|
||||
config = main.config,
|
||||
dir = DIR,
|
||||
gzip = zlib.createGzip(),
|
||||
p = params,
|
||||
isGzip = main.isGZIP(p.request),
|
||||
path = params.name,
|
||||
isGzip = main.isGZIP(request),
|
||||
|
||||
parsedUrl = URL.parse(request.url),
|
||||
path = parsedUrl.pathname,
|
||||
|
||||
isJoin = CloudFunc.isJoinURL(path),
|
||||
readPipe = function() {
|
||||
main.mainSetHeader({
|
||||
name : names[0],
|
||||
cache : config.cache,
|
||||
gzip : isGzip,
|
||||
request : p.request,
|
||||
response : p.response
|
||||
request : request,
|
||||
response : response
|
||||
});
|
||||
|
||||
if (!isGzip)
|
||||
stream = p.response;
|
||||
stream = response;
|
||||
else
|
||||
stream = gzip;
|
||||
|
||||
|
|
@ -257,15 +261,14 @@
|
|||
callback : function(error) {
|
||||
var errorStr;
|
||||
|
||||
if (error) {
|
||||
if (!p.response.headersSent)
|
||||
main.sendError(params, error);
|
||||
if (error)
|
||||
if (!response.headersSent)
|
||||
Util.exec(callback, error);
|
||||
else {
|
||||
Util.log(error);
|
||||
errorStr = error.toString();
|
||||
stream.end(errorStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -274,7 +277,7 @@
|
|||
* readPipe called with stream param
|
||||
*/
|
||||
if (isGzip)
|
||||
gzip.pipe(p.response);
|
||||
gzip.pipe(response);
|
||||
};
|
||||
|
||||
if (isJoin) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue