public static final class Http.RequestBody
extends java.lang.Object
Constructor and Description |
---|
RequestBody(java.lang.Object body) |
Modifier and Type | Method and Description |
---|---|
<T> T |
as(java.lang.Class<T> tType)
Cast this RequestBody as T if possible.
|
akka.util.ByteString |
asBytes()
The request content as a ByteString.
|
java.util.Map<java.lang.String,java.lang.String[]> |
asFormUrlEncoded()
The request content parsed as URL form-encoded.
|
com.fasterxml.jackson.databind.JsonNode |
asJson() |
<A> Http.MultipartFormData<A> |
asMultipartFormData()
The request content parsed as multipart form data.
|
Http.RawBuffer |
asRaw() |
java.lang.String |
asText() |
org.w3c.dom.Document |
asXml() |
<A> java.util.Optional<A> |
parseJson(java.lang.Class<A> clazz)
Converts a JSON request to a given class.
|
java.lang.String |
toString() |
public <A> Http.MultipartFormData<A> asMultipartFormData()
A
- the file type (e.g. play.api.libs.Files.TemporaryFile)public java.util.Map<java.lang.String,java.lang.String[]> asFormUrlEncoded()
public Http.RawBuffer asRaw()
public java.lang.String asText()
public org.w3c.dom.Document asXml()
public com.fasterxml.jackson.databind.JsonNode asJson()
public <A> java.util.Optional<A> parseJson(java.lang.Class<A> clazz)
Will return Optional.empty() if the request body is not an instance of JsonNode. If the JsonNode simply has missing fields, a valid reference with null fields is returne.
A
- The type to convert the JSON value to.clazz
- The class to convert the JSON value to.public akka.util.ByteString asBytes()
This makes a best effort attempt to convert the parsed body to a ByteString, if it knows how. This includes String, json, XML and form bodies. It doesn't include multipart/form-data or raw bodies that don't fit in the configured max memory buffer, nor does it include custom output types from custom body parsers.
public <T> T as(java.lang.Class<T> tType)
T
- type of the provided tType
tType
- class that we are trying to cast the body aspublic java.lang.String toString()
toString
in class java.lang.Object