mirror of
https://github.com/alibaba/anyproxy.git
synced 2025-05-10 14:58:27 +00:00
update doc
This commit is contained in:
parent
331bb8067d
commit
64658975d8
@ -71,7 +71,7 @@ Rule module
|
||||
* 改变服务端响应的http状态码
|
||||
* **[rule_use_local_data.js](./rule_sample/rule_use_local_data.js)**
|
||||
* map some requests to local file
|
||||
* 把响应映射到本地
|
||||
* 把图片响应映射到本地
|
||||
|
||||
* and here is the scheme in rule module
|
||||
|
||||
|
@ -11,8 +11,6 @@ module.exports = {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//=======================
|
||||
//when getting a request from user
|
||||
//收到用户请求之后
|
||||
@ -21,6 +19,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
|
||||
//req is the user's request sent to the proxy server
|
||||
shouldUseLocalResponse : function(req,reqBody){
|
||||
return false;
|
||||
},
|
||||
@ -36,10 +35,6 @@ module.exports = {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//=======================
|
||||
//when ready to send a request to server
|
||||
//向服务端发出请求之前
|
||||
@ -54,9 +49,9 @@ module.exports = {
|
||||
},
|
||||
|
||||
//替换向服务器发出的请求参数(option)
|
||||
//req is user's request which will be sent to the proxy server, docs : http://nodejs.org/api/http.html#http_http_request_options_callback
|
||||
//you may return a customized option to replace the original option
|
||||
//you should not write content-length header in options, since anyproxy will handle it for you
|
||||
//option is the configuration of the http request sent to remote server. You may refers to http://nodejs.org/api/http.html#http_http_request_options_callback
|
||||
//you may return a customized option to replace the original one
|
||||
//you should not overwrite content-length header in options, since anyproxy will handle it for you
|
||||
replaceRequestOption : function(req,option){
|
||||
var newOption = option;
|
||||
return newOption;
|
||||
@ -70,8 +65,6 @@ module.exports = {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//=======================
|
||||
//when ready to send the response to user after receiving response from server
|
||||
//向用户返回服务端的响应之前
|
||||
@ -114,9 +107,6 @@ module.exports = {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//=======================
|
||||
//https config
|
||||
//=======================
|
||||
|
@ -5,6 +5,10 @@ var LOCAL_IMAGE = "/Users/path/to/image.png";
|
||||
|
||||
module.exports = {
|
||||
|
||||
summary:function(){
|
||||
return "replace all the images with local one";
|
||||
},
|
||||
|
||||
//mark if use local response
|
||||
shouldUseLocalResponse : function(req,reqBody){
|
||||
if(/\.(png|gif|jpg|jpeg)$/.test(req.url)){
|
||||
|
Loading…
x
Reference in New Issue
Block a user