Last active
January 22, 2018 04:56
-
-
Save benburton/dad3fe53efb689f0940c to your computer and use it in GitHub Desktop.
An example of using the Play-WS library without the Play! Framework
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.benburton | |
import com.ning.http.client.AsyncHttpClientConfig | |
import play.api.libs.ws.WSResponse | |
import play.api.libs.ws.ning.NingWSClient | |
import scala.concurrent.duration.Duration | |
import scala.concurrent.{Await, Future} | |
object PlayWSWithoutPlayExample extends App { | |
val timeout = 60000 * 10 | |
val builder = new AsyncHttpClientConfig.Builder() | |
val client = new NingWSClient(builder.setConnectionTimeoutInMs(timeout).setRequestTimeoutInMs(timeout) | |
.setIdleConnectionTimeoutInMs(timeout).build()) | |
val responseFuture: Future[WSResponse] = | |
client.url("https://twitter.com/Niklas_L/status/586572487305093120").get() | |
val result = Await.result(responseFuture, Duration.Inf) | |
client.close() | |
println(result.body) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment