Constructor and Description |
---|
RequestBody(Object body) |
Modifier and Type | Method and Description |
---|---|
<T> T |
as(Class<T> tType)
Cast this RequestBody as T if possible.
|
akka.util.ByteString |
asBytes()
The request content as a ByteString.
|
Map<String,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() |
String |
asText() |
Document |
asXml() |
<A> Optional<A> |
parseJson(Class<A> clazz)
Converts a JSON request to a given class.
|
String |
toString() |
public RequestBody(Object body)
public <A> Http.MultipartFormData<A> asMultipartFormData()
A
- the file type (e.g. play.api.libs.Files.TemporaryFile)public Map<String,String[]> asFormUrlEncoded()
public Http.RawBuffer asRaw()
public String asText()
public Document asXml()
public com.fasterxml.jackson.databind.JsonNode asJson()
public <A> Optional<A> parseJson(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(Class<T> tType)
T
- type of the provided tType
tType
- class that we are trying to cast the body as