title: How to do custom action composition to log request and response in Play 2.3?
body: <p>I'm working on Play 2.3 (Java) application and I need a custom Action Composition to log request and response. With what I've got so far I am able to get the body of request, but not response:</p>
  
  <pre><code>import play.libs.F;
  import play.mvc.Action;
  import play.mvc.Http;
  import play.mvc.Result;
  
  public class LogAction extends Action.Simple {
  
      public F.Promise&lt;Result&gt; call(Http.Context ctx) throws Throwable {
          //Request body
          String requestBody = ctx.request().body().asText();
          //Need to get response body here
          //String responseBody = ???
          return delegate.call(ctx);
      }
  
  }
  </code></pre>
  
  <p>How to I get the response body in this scenario? If it's difficult to do in java, it may as well be in scala, however it has to work with a java controller method <code>@With</code> annotation.</p>