Skip to content

Print POST body request before transform the response, how ? #12

@droidrcc

Description

@droidrcc

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions