public CompletionStage<Result> index() {
return ws.url(feedUrl).get().thenApply(response ->
ok("Feed title: " + response.asJson().findPath("title").asText())
);
}--
You received this message because you are subscribed to the Google Groups "Play Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framework+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/386b89b0-bdf6-4e37-8d7a-c3f56095b32f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You can do this by mapping through the response using thenApply:public CompletionStage<Result> index() { return ws.url(feedUrl).get().thenApply(response -> ok("Feed title: " + response.asJson().findPath("title").asText()) ); }
On Tue, Jan 24, 2017 at 2:36 AM, Chun How Ng <chunh...@gmail.com> wrote:
Hi,
I have a WSResponse object from executing an HTTP call via WSClient's get() and it contains a HTML page.I'm wondering Is there any solution in Java to convert play.libs.ws.WSResponse object to a play.mvc.Result?*I'm on Play v2.5.8
--
You received this message because you are subscribed to the Google Groups "Play Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framework+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/a055a389-48cc-4fe9-8843-407ec49273fd%40googlegroups.com.
def responseToResult(response: WSResponse): Result = {
val headers = response.allHeaders map { h => (h._1, h._2.head) }
val entity = HttpEntity.Strict(
ByteString(response.body.getBytes),
response.allHeaders.get("Content-Type").map(_.head)
)
Result(ResponseHeader(response.status, headers), entity)
}
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/CAJmgB63%3DD6BrL34TvgqPhRa_mRoB9d-a%3DOvVryBU7Mn39QBstg%40mail.gmail.com.