【发布时间】:2016-03-14 11:47:32
【问题描述】:
我正在尝试创建自定义 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;
}
}
【问题讨论】:
标签: java http playframework playframework-2.0 playframework-2.5