Package

play.api.libs

ws

Permalink

package ws

Visibility
  1. Public
  2. All

Type Members

  1. case class DefaultWSProxyServer(host: String, port: Int, protocol: Option[String] = None, principal: Option[String] = None, password: Option[String] = None, ntlmDomain: Option[String] = None, encoding: Option[String] = None, nonProxyHosts: Option[Seq[String]] = None) extends WSProxyServer with Product with Serializable

    Permalink

    A WS proxy.

  2. case class DefaultWSResponseHeaders(status: Int, headers: Map[String, Seq[String]]) extends WSResponseHeaders with Product with Serializable

    Permalink
  3. case class FileBody(file: File) extends WSBody with Product with Serializable

    Permalink

    A file body

  4. case class InMemoryBody(bytes: ByteString) extends WSBody with Product with Serializable

    Permalink

    An in memory body

    An in memory body

    bytes

    The bytes of the body

  5. case class StreamedBody(bytes: Source[ByteString, _]) extends WSBody with Product with Serializable

    Permalink

    A streamed body

    A streamed body

    bytes

    A flow of the bytes of the body

  6. case class StreamedResponse(headers: WSResponseHeaders, body: Source[ByteString, _]) extends Product with Serializable

    Permalink

    A streamed response containing a response header and a streamable body.

  7. trait WSAPI extends AnyRef

    Permalink

    The base WS API trait.

  8. trait WSAuthScheme extends AnyRef

    Permalink

  9. sealed trait WSBody extends AnyRef

    Permalink

    A body for the request

  10. trait WSClient extends Closeable

    Permalink

    The WSClient holds the configuration information needed to build a request, and provides a way to get a request holder.

  11. case class WSClientConfig(connectionTimeout: Duration = 2.minutes, idleTimeout: Duration = 2.minutes, requestTimeout: Duration = 2.minutes, followRedirects: Boolean = true, useProxyProperties: Boolean = true, userAgent: Option[String] = None, compressionEnabled: Boolean = false, ssl: SSLConfig = SSLConfig()) extends Product with Serializable

    Permalink

    WS client config

  12. class WSConfigParser extends Provider[WSClientConfig]

    Permalink

    This class creates a DefaultWSClientConfig object from the play.api.Configuration.

    This class creates a DefaultWSClientConfig object from the play.api.Configuration.

    Annotations
    @Singleton()
  13. trait WSCookie extends AnyRef

    Permalink

    A WS Cookie.

    A WS Cookie. This is a trait so that we are not tied to a specific client.

  14. trait WSProxyServer extends AnyRef

    Permalink

    A WS proxy.

  15. trait WSRequest extends AnyRef

    Permalink

    A WS Request builder.

  16. trait WSRequestExecutor extends AnyRef

    Permalink
  17. trait WSRequestFilter extends AnyRef

    Permalink
  18. trait WSRequestMagnet extends AnyRef

    Permalink

    WSRequestMagnet magnet.

    WSRequestMagnet magnet. Please see the companion object for implicit definitions.

    See also

    The magnet pattern

  19. trait WSResponse extends AnyRef

    Permalink

  20. trait WSResponseHeaders extends AnyRef

    Permalink

    An HTTP response header (the body has not been retrieved yet)

  21. trait WSSignatureCalculator extends AnyRef

    Permalink

    Sign a WS call with OAuth.

Value Members

  1. object EmptyBody extends WSBody with Product with Serializable

    Permalink

    An empty body

  2. object WSAuthScheme

    Permalink
  3. package ahc

    Permalink
  4. package ning

    Permalink
  5. package ssl

    Permalink

Deprecated Value Members

  1. object WS

    Permalink

    Asynchronous API to to query web services, as an http client.

    Asynchronous API to to query web services, as an http client.

    Usage example:

    class MyService @Inject() (ws: WSClient) {
      ws.url("http://example.com/feed").get()
      ws.url("http://example.com/item").post("content")
    }

    When greater flexibility is needed, you can also create clients explicitly and pass them into WS:

    import play.api.libs.ws._
    import play.api.libs.ws.ahc._
    import akka.stream.Materializer
    import play.api.ApplicationLifecycle
    import javax.inject.Inject
    import scala.concurrent.Future
    
    class MyService @Inject() (lifecycle: ApplicationLifecycle)(implicit mat: Materializer) {
      private val client = new AhcWSClient(new AhcConfigBuilder().build())
      client.url("http://example.com/feed").get()
      lifecycle.addStopHook(() =>
        // Make sure you close the client after use, otherwise you'll leak threads and connections
        client.close()
        Future.successful(())
      }
    }

    Or call the client directly:

    import com.typesafe.config.ConfigFactory
    import play.api.libs.ws._
    import play.api.libs.ws.ahc._
    
    val configuration = play.api.Configuration(ConfigFactory.parseString(
    """
      |play.ws.ssl.trustManager = ...
    """.stripMargin))
    val parser = new DefaultWSConfigParser(configuration, app.classloader)
    val builder = new AhcConfigBuilder(parser.parse())
    val secureClient: WSClient = new AhcWSClient(builder.build())
    val response = secureClient.url("https://secure.com").get()
    secureClient.close() // must explicitly manage lifecycle

    The value returned is a Future[WSResponse], and you should use Play's asynchronous mechanisms to use this response.

    Annotations
    @deprecated
    Deprecated

    (Since version 2.5.0) Inject WSClient into your component

Ungrouped