transformer-proxy
transformer-proxy copied to clipboard
Print POST body request before transform the response, how ?
It is possible to print the POST body request before to transform the response ?
var http = require('http'),
connect = require('connect'),
httpProxy = require('http-proxy'),
transformerProxy = require('transformer-proxy');
var transformerFunction = function (data, req, res) {
/*var json = convert.xml2json(data, {compact: true, spaces: 4});*/
return data;
};
var app = connect();
var proxy = httpProxy.createProxyServer({
target: 'https://localhost:9000',
secure: false
});
proxy.on('proxyReq', function(proxyReq, req, res, options) {
console.log("proxyReq:", proxyReq);
});
app.use(transformerProxy(transformerFunction));
app.use(function (req, res) {
proxy.web(req, res);
});
http.createServer(app).listen(8000);
Thanks, D