2014-08-13 11:51:39 +08:00
var rules = {
"map" : [
{
2014-08-13 17:30:16 +08:00
"host" : /./ , //regExp
"path" : /\/path\/test/ , //regExp
"localFile" : "" , //this file will be returned to user when host and path pattern both meets the request
"localDir" : "~/" //find the file of same name in localdir. anyproxy will not read localDir settings unless localFile is falsy
2014-08-13 11:51:39 +08:00
}
2014-08-18 19:51:15 +08:00
// ,{
// "host" :/./,
// "path" :/\.(png|gif|jpg|jpeg)/,
// "localFile" :"/Users/Stella/tmp/test.png",
// "localDir" :"~/"
// }
2014-08-13 11:51:39 +08:00
, {
"host" : /./ ,
2014-08-18 19:51:15 +08:00
"path" : /tps/ ,
"localFile" : "" ,
"localDir" : "/Users/Stella/tmp/"
2014-08-22 23:49:46 +08:00
} , {
"host" : /./ ,
2014-08-24 14:09:18 +08:00
"path" : /response\.(json)/ ,
2014-08-22 23:49:46 +08:00
"sleep" : 5 //seconds
2014-08-24 14:09:18 +08:00
} , {
"host" : /./ ,
"path" : /(.*)\.html/ ,
"callback" : function ( res ) {
//remoty.js will be inject into response via callback
res . write ( "<script type=\"text\/javascript\" src=\"http:\/\/localhost:3001\/remoty\.js\"><\/script>" ) ;
res . write ( "<script type=\"text\/javascript\" src=\"http:\/\/localhost:8080\/target\/target\-script\-min\.js\#anonymous\"><\/script>" ) ;
}
2014-08-13 11:51:39 +08:00
}
]
, "httpsConfig" : {
2014-08-13 17:30:16 +08:00
"bypassAll" : false , //by setting this to true, anyproxy will not intercept any https request
"interceptDomains" : [ /www\.a\.com/ , /www\.b\.com/ ] //by setting bypassAll:false, requests towards these domains will be intercepted, and try to meet the map rules above
2014-08-13 11:51:39 +08:00
}
}
module . exports = rules ;