mirror of
https://github.com/alibaba/anyproxy.git
synced 2025-07-29 00:59:10 +00:00
update doc
This commit is contained in:
@@ -1,12 +0,0 @@
|
||||
## rule files sample
|
||||
|
||||
* **rule__blank.js**, blank rule file with some comments. You may read this before writing your own rule file.
|
||||
|
||||
* **rule_adjust_response_time.js**, delay all the response for 1500ms
|
||||
* **rule_allow_CORS.js**, add CORS headers to allow cross-domain ajax request
|
||||
* **rule_intercept_some_https_requests.js**, intercept https requests toward github.com
|
||||
* **rule_remove_cache_header.js**, remove all cache-related headers from server
|
||||
* **rule_replace_request_option.js**, replace request parameters before sending to the server
|
||||
* **rule_replace_response_data.js**, modify response data
|
||||
* **rule_replace_response_status_code.js**, replace server's status code
|
||||
* **rule_use_local_data.js**, map some requests to local file
|
@@ -6,11 +6,7 @@ module.exports = {
|
||||
//whether to intercept this request by local logic
|
||||
//if the return value is true, anyproxy will call dealLocalResponse to get response data and will not send request to remote server anymore
|
||||
shouldUseLocalResponse : function(req,reqBody){
|
||||
if(/hello/.test(reqBody.toString())){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
//you may deal the response locally instead of sending it to server
|
||||
|
@@ -1,6 +1,14 @@
|
||||
//rule scheme :
|
||||
|
||||
module.exports = {
|
||||
replaceRequestOption : function(req,option){
|
||||
var newOption = option;
|
||||
delete newOption.headers['if-none-match'];
|
||||
delete newOption.headers['if-modified-since'];
|
||||
|
||||
return newOption;
|
||||
},
|
||||
|
||||
replaceResponseHeader: function(req,res,header){
|
||||
header = header || {};
|
||||
header["Cache-Control"] = "no-cache, no-store, must-revalidate";
|
||||
|
Reference in New Issue
Block a user