title: Log request/responses bodies with http-proxy-middleware
body: <p>I'm using <a href="https://github.com/chimurai/http-proxy-middleware" rel="noreferrer">http-proxy-middleware</a> to implement a transparent proxy.</p>
  
  <p>I'd like to do request/response inspection. I mean, I'd like to print in a text file request/responses that go through the proxy whithout do any modifying on them. </p>
  
  <p>Up to now, what I'm using is something like that (simplified version):</p>
  
  <pre><code>app.use('/proxy/:service/', proxy({
          pathRewrite: function(path, req){
              ...
          },
          router: function(req) {
              ...
          },
          onProxyRes: function(proxyRes, req, res) {
              log("Req URL: " + req.originalUrl);
              log("Response status code: " + proxyRes.statusCode);
          }
  }));
  </code></pre>
  
  <p>(<code>log()</code> is a helper function that uses a string as input and prints it is my log file)</p>
  
  <p>Thus, basically I'm using <code>onProxyRes</code> to intercept the response and do logging at that point. The problem is that I have been only able to make it work for things like URL, status code, headers, etc. but I haven't find the payload body in <code>req</code> and/or <code>resProxy</code> objects.</p>
  
  <p>I have read about how to get the <code>res</code> body <a href="https://github.com/chimurai/http-proxy-middleware/issues/97" rel="noreferrer">here</a>. However, it seems to be complex  solution (needs to set a <code>data</code> event handler). And it doesn't cover the <code>req</code> body, as far as I understand.</p>
  
  <p>Any hint/help/reference is hightly appreciated, please. Not sure if even using <code>onProxyRes</code> is the best way of implementing this, maybe the library provides some functionality to cover the request/response case.</p>