public interface Response<T>
withHeader(String, String)
. These will create new copies of the
Response
object.Modifier and Type | Method and Description |
---|---|
static <T> Response<T> |
forPayload(T payload)
Creates a 200 OK
Response with the given payload of type T . |
static <T> Response<T> |
forStatus(StatusType statusCode)
Creates a
Response with the given status code. |
Map<String,String> |
headers()
The response headers.
|
static <T> Response<T> |
of(StatusType statusCode,
T payload)
Creates a
Response with the given status code and a payload with type T . |
static <T> Response<T> |
ok()
Returns a typed 200 OK
Response . |
Optional<T> |
payload()
The single payload of the response.
|
StatusType |
status()
The status of the response message.
|
Response<T> |
withHeader(String header,
String value)
Creates a new
Response based on this, but with an additional header. |
Response<T> |
withHeaders(Map<String,String> headers)
Creates a new
Response based on this, but with additional headers. |
<P> Response<P> |
withPayload(P newPayload)
Creates a new
Response based on this, but with a different payload. |
StatusType status()
Response<T> withHeader(String header, String value)
Response
based on this, but with an additional header.header
- Header name to addvalue
- Header valueResponse<T> withHeaders(Map<String,String> headers)
Response
based on this, but with additional headers.headers
- Map of header name-values to add<P> Response<P> withPayload(@Nullable P newPayload)
Response
based on this, but with a different payload. Status code,
headers, etc., are copied over. To clear out the payload, one can pass in null
.newPayload
- the new payloadstatic <T> Response<T> ok()
Response
.T
- The response payload typestatic <T> Response<T> forStatus(StatusType statusCode)
Response
with the given status code.
If code
is OK, this function will be equivalent to ok()
.T
- The response payload typestatusCode
- The status codestatic <T> Response<T> forPayload(T payload)
Response
with the given payload of type T
.T
- The response payload typepayload
- The payload to respond withstatic <T> Response<T> of(StatusType statusCode, T payload)
Response
with the given status code and a payload with type T
.T
- The response payload typestatusCode
- The status codepayload
- The payload to respond withCopyright © 2016. All rights reserved.