Skip to content

Instantly share code, notes, and snippets.

@benburton
Last active January 22, 2018 04:56
Show Gist options
  • Save benburton/dad3fe53efb689f0940c to your computer and use it in GitHub Desktop.
Save benburton/dad3fe53efb689f0940c to your computer and use it in GitHub Desktop.
An example of using the Play-WS library without the Play! Framework
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