onProxyReq(proxyReq, req, res) {
if ( req.method == "POST" && req.body ) {
// Add req.body logic here if needed....
// ....
// Remove body-parser body object from the request
if ( req.body ) delete req.body;
// Make any needed POST parameter changes
let body = new Object();
body.filename = 'reports/statistics/summary_2016.pdf';
body.routeid = 's003b012d002';
body.authid = 'bac02c1d-258a-4177-9da6-862580154960';
// URI encode JSON object
body = Object.keys( body ).map(function( key ) {
return encodeURIComponent( key ) + '=' + encodeURIComponent( body[ key ])
}).join('&');
// Update header
proxyReq.setHeader( 'content-type', 'application/x-www-form-urlencoded' );
proxyReq.setHeader( 'content-length', body.length );
// Write out body changes to the proxyReq stream
proxyReq.write( body );
proxyReq.end();
}
}
koa onProxyReq
2088

被折叠的 条评论
为什么被折叠?



