play.api.libs.ws

Provides implicit type classes when you import the package.

Attributes

Members list

Type members

Classlikes

trait WSBodyReadables extends DefaultBodyReadables, JsonBodyReadables, XMLBodyReadables

JSON, XML and Multipart Form Data Readables used for Play-WS bodies.

JSON, XML and Multipart Form Data Readables used for Play-WS bodies.

Attributes

Companion
object
Supertypes
trait XMLBodyReadables
trait JsonBodyReadables
trait DefaultBodyReadables
class Object
trait Matchable
class Any
Show all
Known subtypes
object WSBodyReadables.type
trait WSResponse

Attributes

Companion
trait
Supertypes
trait XMLBodyReadables
trait JsonBodyReadables
trait DefaultBodyReadables
class Object
trait Matchable
class Any
Show all
Self type
trait WSBodyWritables extends DefaultBodyWritables, JsonBodyWritables, XMLBodyWritables

JSON, XML and Multipart Form Data Writables used for Play-WS bodies.

JSON, XML and Multipart Form Data Writables used for Play-WS bodies.

Attributes

Companion
object
Supertypes
trait XMLBodyWritables
trait JsonBodyWritables
trait DefaultBodyWritables
class Object
trait Matchable
class Any
Show all
Known subtypes
object WSBodyWritables.type
trait WSRequest

Attributes

Companion
trait
Supertypes
trait XMLBodyWritables
trait JsonBodyWritables
trait DefaultBodyWritables
class Object
trait Matchable
class Any
Show all
Self type
trait WSClient extends Closeable

A Play specific WS client that can use Play specific classes in the request and response building.

A Play specific WS client that can use Play specific classes in the request and response building.

Typically, access this class through dependency injection, i.e.

 class MyService @Inject()(ws: WSClient) {
   val response: Future[WSResponse] = ws.url("https://example.com").get()
 }

Please see the documentation at https://www.playframework.com/documentation/latest/ScalaWS for more details.

Attributes

Supertypes
trait Closeable
trait AutoCloseable
class Object
trait Matchable
class Any
trait WSRequest extends StandaloneWSRequest, WSBodyWritables

A WS Request builder.

A WS Request builder.

Attributes

Supertypes
trait XMLBodyWritables
trait JsonBodyWritables
trait DefaultBodyWritables
trait StandaloneWSRequest
class Object
trait Matchable
class Any
Show all
trait WSResponse extends StandaloneWSResponse, WSBodyReadables

A WS Response that can use Play specific classes.

A WS Response that can use Play specific classes.

Attributes

Supertypes
trait XMLBodyReadables
trait JsonBodyReadables
trait DefaultBodyReadables
trait StandaloneWSResponse
class Object
trait Matchable
class Any
Show all

Value members

Inherited methods

def body(objectMapper: ObjectMapper): BodyWritable[JsonNode]

Attributes

Inherited from:
JsonBodyWritables

Implicits

Inherited implicits

implicit val bodyWritableOf_Multipart: BodyWritable[Source[Part[Source[ByteString, _]], _]]

Attributes

Inherited from:
WSBodyWritables
implicit val readableAsByteArray: BodyReadable[Array[Byte]]

Converts a response body into Array[Byte].

Converts a response body into Array[Byte].

import play.api.libs.ws.DefaultBodyReadables._

def example(response: play.api.libs.ws.StandaloneWSResponse): Array[Byte] =
 response.body[Array[Byte]]

Attributes

Inherited from:
DefaultBodyReadables
implicit val readableAsByteBuffer: BodyReadable[ByteBuffer]

Converts a response body into a read only ByteBuffer.

Converts a response body into a read only ByteBuffer.

import java.nio.ByteBuffer
import play.api.libs.ws.DefaultBodyReadables._

def example(response: play.api.libs.ws.StandaloneWSResponse): ByteBuffer =
 response.body[ByteBuffer]

Attributes

Inherited from:
DefaultBodyReadables
implicit val readableAsByteString: BodyReadable[ByteString]

Converts a response body into an akka.util.ByteString:

Converts a response body into an akka.util.ByteString:

import akka.util.ByteString
import play.api.libs.ws.DefaultBodyReadables._

def example(response: play.api.libs.ws.StandaloneWSResponse): ByteString =
 response.body[ByteString]

Attributes

Inherited from:
DefaultBodyReadables
implicit val readableAsJson: BodyReadable[JsValue]

Converts a response body into Play JSON format:

Converts a response body into Play JSON format:

import play.api.libs.ws.StandaloneWSResponse
import play.api.libs.ws.JsonBodyReadables._

def json(r: StandaloneWSResponse) = r.body[play.api.libs.json.JsValue]

Attributes

Inherited from:
JsonBodyReadables
implicit val readableAsSource: BodyReadable[Source[ByteString, _]]

Converts a response body into Source[ByteString, _].

Converts a response body into Source[ByteString, _].

Attributes

Inherited from:
DefaultBodyReadables
implicit val readableAsString: BodyReadable[String]

Converts a response body into a String.

Converts a response body into a String.

Note: this is only a best-guess effort and does not handle all content types. See StandaloneWSResponse.body:String* for more information.

import play.api.libs.ws.DefaultBodyReadables._

def example(response: play.api.libs.ws.StandaloneWSResponse): String =
 response.body[String]

Attributes

Inherited from:
DefaultBodyReadables
implicit val readableAsXml: BodyReadable[Elem]

Converts a response body into XML document:

Converts a response body into XML document:

import scala.xml.Elem

import play.api.libs.ws.StandaloneWSResponse
import play.api.libs.ws.XMLBodyReadables._

def foo(resp: StandaloneWSResponse): Elem = resp.body[Elem]

Attributes

Inherited from:
XMLBodyReadables
implicit val writableOf_File: BodyWritable[File]

Creates an SourceBody with "application/octet-stream" content type from a file.

Creates an SourceBody with "application/octet-stream" content type from a file.

Attributes

Inherited from:
DefaultBodyWritables
implicit val writableOf_InputStream: BodyWritable[Supplier[InputStream]]

Creates an SourceBody with "application/octet-stream" content type from an inputstream.

Creates an SourceBody with "application/octet-stream" content type from an inputstream.

Attributes

Inherited from:
DefaultBodyWritables
implicit val writableOf_Source: BodyWritable[Source[ByteString, _]]

Creates an SourceBody with "application/octet-stream" content type from a file.

Creates an SourceBody with "application/octet-stream" content type from a file.

Attributes

Inherited from:
DefaultBodyWritables
implicit val writeableOf_ByteArray: BodyWritable[Array[Byte]]

Creates an InMemoryBody with "application/octet-stream" content type from an array of bytes.

Creates an InMemoryBody with "application/octet-stream" content type from an array of bytes.

Attributes

Inherited from:
DefaultBodyWritables
implicit val writeableOf_ByteBuffer: BodyWritable[ByteBuffer]

Creates an InMemoryBody with "application/octet-stream" content type from a bytebuffer.

Creates an InMemoryBody with "application/octet-stream" content type from a bytebuffer.

Attributes

Inherited from:
DefaultBodyWritables
implicit val writeableOf_Bytes: BodyWritable[ByteString]

Creates an InMemoryBody with "application/octet-stream" content type.

Creates an InMemoryBody with "application/octet-stream" content type.

Attributes

Inherited from:
DefaultBodyWritables
implicit val writeableOf_Document: BodyWritable[Document]

Creates an InMemoryBody with "text/xml" content type.

Creates an InMemoryBody with "text/xml" content type.

Attributes

Inherited from:
XMLBodyWritables
implicit val writeableOf_JsValue: BodyWritable[JsValue]

Creates an InMemoryBody with "application/json" content type, using the static ObjectMapper.

Creates an InMemoryBody with "application/json" content type, using the static ObjectMapper.

Attributes

Inherited from:
JsonBodyWritables
implicit val writeableOf_NodeBuffer: BodyWritable[NodeBuffer]

Creates an InMemoryBody with "text/xml" content type.

Creates an InMemoryBody with "text/xml" content type.

Attributes

Inherited from:
XMLBodyWritables
implicit def writeableOf_NodeSeq[C <: NodeSeq]: BodyWritable[C]

Creates an InMemoryBody with "text/xml" content type.

Creates an InMemoryBody with "text/xml" content type.

Attributes

Inherited from:
XMLBodyWritables
implicit val writeableOf_String: BodyWritable[String]

Creates an InMemoryBody with "text/plain" content type.

Creates an InMemoryBody with "text/plain" content type.

Attributes

Inherited from:
DefaultBodyWritables
implicit val writeableOf_StringBuilder: BodyWritable[StringBuilder]

Creates an InMemoryBody with "text/plain" content type from a StringBuilder

Creates an InMemoryBody with "text/plain" content type from a StringBuilder

Attributes

Inherited from:
DefaultBodyWritables
implicit val writeableOf_WsBody: BodyWritable[WSBody]

Creates a BodyWritable with an identity function, with "application/octet-stream" content type.

Creates a BodyWritable with an identity function, with "application/octet-stream" content type.

Attributes

Inherited from:
DefaultBodyWritables
implicit val writeableOf_urlEncodedForm: BodyWritable[Map[String, Seq[String]]]

Creates an InMemoryBody with "application/x-www-form-urlencoded" content type.

Creates an InMemoryBody with "application/x-www-form-urlencoded" content type.

Attributes

Inherited from:
DefaultBodyWritables
implicit val writeableOf_urlEncodedSimpleForm: BodyWritable[Map[String, String]]

Attributes

Inherited from:
DefaultBodyWritables