Prepares a new request using an implicit client.
Prepares a new request using an implicit client. The client must be in scope and configured, i.e.
implicit val sslClient = new play.api.libs.ws.ahc.AhcWSClient(sslBuilder.build()) WS.clientUrl("http://example.com/feed")
the URL to request
the client to use to make the request.
Prepares a new request using a provided magnet.
Prepares a new request using a provided magnet. This method gives you the ability to create your own URL implementations at the cost of some complexity.
object PairMagnet { implicit def fromPair(pair: Pair[WSClient, java.net.URL]) = new WSRequestHolderMagnet { def apply(): WSRequestHolder = { val (client, netUrl) = pair client.url(netUrl.toString) } } } import scala.language.implicitConversions val client = WS.client val exampleURL = new java.net.URL("http://example.com") WS.url(client -> exampleURL).get()
a magnet pattern.
Retrieves or creates underlying HTTP client.
Retrieves or creates underlying HTTP client. Note that due to the Plugin architecture, an implicit application must be in scope. Most of the time you will want the current app:
val client = WS.client(app)
(Since version 2.5.0) Inject WSClient into your component
Prepares a new request using an implicit application.
Prepares a new request using an implicit application. This creates a default client, which you can then use to construct a request.
WS.url("http://localhost/")(app).get()
the URL to request
the implicit application to use.
(Since version 2.5.0) Inject WSClient into your component
Asynchronous API to to query web services, as an http client.
Usage example:
When greater flexibility is needed, you can also create clients explicitly and pass them into WS:
Or call the client directly:
The value returned is a
Future[WSResponse]
, and you should use Play's asynchronous mechanisms to use this response.(Since version 2.5.0) Inject WSClient into your component