我正在尝试创建一个自定义 http 操作(https://playframework.com/documentation/2.5.x/JavaActionsComposition)以使用 Play 2.5.0 Java 记录请求和响应主体。这是我到目前为止所得到的:
public class Log extends play.mvc.Action.Simple {
public CompletionStage<Result> call(Http.Context ctx) {
CompletionStage<Result> response = delegate.call(ctx);
//request body is fine
System.out.println(ctx.request().body().asText())
//how to get response body string here while also not sabotaging http response flow of the framework?
//my guess is it should be somehow possible to access it below?
response.thenApply( r -> {
//???
return null;
});
return response;
}
}