title: How to print a response body in actix_web middleware?
body: <p>I'd like to write a very simple middleware using <a href="https://docs.rs/actix-web/3.1.0/actix_web/index.html" rel="nofollow noreferrer"><code>actix_web</code></a> framework but it's so far beating me on every front.</p>
  <p>I have a skeleton like this:</p>
  <pre class="lang-rust prettyprint-override"><code>let result = actix_web::HttpServer::new(move || {
      actix_web::App::new()
          .wrap_fn(move |req, srv| {
              srv.call(req).map(move|res| {
                  println!(&quot;Got response&quot;);
                  // let s = res.unwrap().response().body();
                  // ???
                  res
              })
          })
  })
  .bind(&quot;0.0.0.0:8080&quot;)?
  .run()
  .await;
  </code></pre>
  <p>and I can access <a href="https://docs.rs/actix-web/3.1.0/actix_web/dev/enum.ResponseBody.html" rel="nofollow noreferrer"><code>ResponseBody</code></a> type via <code>res.unwrap().response().body()</code> but I don't know what can I do with this.</p>
  <p>Any ideas?</p>