mirror of
https://github.com/alibaba/anyproxy.git
synced 2025-04-22 05:11:00 +00:00
21 lines
517 B
JavaScript
21 lines
517 B
JavaScript
/*
|
|
sample:
|
|
intercept all requests toward httpbin.org, use a local response
|
|
test:
|
|
curl http://httpbin.org/user-agent --proxy http://127.0.0.1:8001
|
|
*/
|
|
module.exports = {
|
|
*beforeSendRequest(requestDetail) {
|
|
const localResponse = {
|
|
statusCode: 200,
|
|
header: { 'Content-Type': 'application/json' },
|
|
body: '{"hello": "this is local response"}'
|
|
};
|
|
if (requestDetail.url.indexOf('http://httpbin.org') === 0) {
|
|
return {
|
|
response: localResponse
|
|
};
|
|
}
|
|
},
|
|
};
|