mirror of
https://github.com/alibaba/anyproxy.git
synced 2025-08-04 21:39:04 +00:00
update to 4.0
This commit is contained in:
18
rule_sample/sample_modify_request_data.js
Normal file
18
rule_sample/sample_modify_request_data.js
Normal file
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
sample:
|
||||
modify the post data towards http://httpbin.org/post
|
||||
test:
|
||||
curl -H "Content-Type: text/plain" -X POST -d 'original post data' http://httpbin.org/post --proxy http://127.0.0.1:8001
|
||||
expected response:
|
||||
{ "data": "i-am-anyproxy-modified-post-data" }
|
||||
*/
|
||||
module.exports = {
|
||||
summary: 'Rule to modify request data',
|
||||
*beforeSendRequest(requestDetail) {
|
||||
if (requestDetail.url.indexOf('http://httpbin.org/post') === 0) {
|
||||
return {
|
||||
requestData: 'i-am-anyproxy-modified-post-data'
|
||||
};
|
||||
}
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user