mirror of
https://github.com/alibaba/anyproxy.git
synced 2025-07-27 07:45:41 +00:00
add ui config server
This commit is contained in:
@@ -79,7 +79,7 @@ function userRequestHandler(req,userRes){
|
||||
}
|
||||
resourceInfo.resHeader = resHeader || {};
|
||||
resourceInfo.resBody = resBody;
|
||||
resourceInfo.length = resBody.length;
|
||||
resourceInfo.length = resBody ? resBody.length : 0;
|
||||
resourceInfo.statusCode = statusCode;
|
||||
|
||||
GLOBAL.recorder && GLOBAL.recorder.updateRecord(resourceInfoId,resourceInfo);
|
||||
@@ -171,12 +171,12 @@ function userRequestHandler(req,userRes){
|
||||
|
||||
//send response
|
||||
},function(callback){
|
||||
if(404 == statusCode){
|
||||
var html404path = pathUtil.join(__dirname, '..', 'web', '404.html');
|
||||
userRes.end(fs.readFileSync(html404path));
|
||||
}else{
|
||||
// if(404 == statusCode){
|
||||
// var html404path = pathUtil.join(__dirname, '..', 'web', '404.html');
|
||||
// userRes.end(fs.readFileSync(html404path));
|
||||
// }else{
|
||||
userRes.end(serverResData);
|
||||
}
|
||||
// }
|
||||
callback();
|
||||
|
||||
//udpate record info
|
||||
@@ -304,14 +304,26 @@ function setRules(newRule){
|
||||
if(!newRule){
|
||||
return;
|
||||
}else{
|
||||
|
||||
if(!newRule.summary){
|
||||
newRule.summary = function(){
|
||||
return "this rule file does not have a summary";
|
||||
};
|
||||
}
|
||||
|
||||
userRule = util.merge(defaultRule,newRule);
|
||||
'function' == typeof(userRule.summary) && userRule.summary();
|
||||
'function' == typeof(userRule.summary) && console.log(userRule.summary());
|
||||
}
|
||||
}
|
||||
|
||||
function getRuleSummary(){
|
||||
return userRule.summary();
|
||||
}
|
||||
|
||||
module.exports.userRequestHandler = userRequestHandler;
|
||||
module.exports.connectReqHandler = connectReqHandler;
|
||||
module.exports.setRules = setRules;
|
||||
module.exports.getRuleSummary = getRuleSummary;
|
||||
|
||||
/*
|
||||
note
|
||||
|
@@ -1,9 +1,10 @@
|
||||
module.exports = {
|
||||
summary:function(){
|
||||
console.log("this is the default rule for anyproxy, which supports CORS request");
|
||||
return "the default rule for anyproxy, which supports CORS request";
|
||||
},
|
||||
|
||||
shouldUseLocalResponse : function(req,reqBody){
|
||||
|
||||
//intercept all options request
|
||||
if(req.method == "OPTIONS"){
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user