public interface Response
| Modifier and Type | Interface and Description |
|---|---|
static class |
Response.Status
Simple static collection of all statuses as constants.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
body()
Returns body content.
|
Response |
body(byte[] body)
Sets the raw body content.
|
Response |
body(java.lang.Object body)
Sets the JSON body content.
|
Response |
body(java.lang.String body)
Sets the body content.
|
Response |
body(java.lang.String body,
ContentType contentType)
Sets the body content and common
content-type. |
byte[] |
bodyBytes()
Returns the raw body content.
|
<T> java.util.List<T> |
bodyList(java.lang.Class<T> componentType)
Returns parsed
body content. |
<K,V> java.util.Map<K,V> |
bodyMap(java.lang.Class<K> keyType,
java.lang.Class<V> valueType)
Returns parsed
body content. |
default <V> java.util.Map<java.lang.String,V> |
bodyMap(java.lang.Class<V> valueType)
REturns parsed
body content. |
<T> T |
bodyValue()
Returns parsed
body content. |
<T> T |
bodyValue(java.lang.Class<T> type)
Returns parsed
body content. |
java.lang.String |
contentType()
Gets the content type header.
|
Response |
contentType(ContentType contentType)
Sets the content type header.
|
Context |
context()
Returns the context that this response belongs to.
|
Response |
cookie(Cookie cookie)
Adds a cookie to the response.
|
Cookie |
cookie(java.lang.String name)
Gets cookie value by name.
|
java.util.Map<java.lang.String,Cookie> |
cookies() |
void |
end()
Closes the response.
|
default void |
end(java.lang.Object body)
Sets the body and clsoes the response.
|
default void |
end(java.lang.String body)
Sets the body content and closes the response.
|
default void |
end(java.lang.String body,
ContentType contentType)
Sets the body content and common
content-type
and closes the response. |
java.lang.String |
header(java.lang.String name)
Gets header value by name.
|
Response |
header(java.lang.String name,
java.lang.String value)
Sets the first header name with the specified value.
|
MultiMap<java.lang.String> |
headers()
Returns headers.
|
boolean |
isCommitted()
Returns
true if response is already committed. |
boolean |
isContentType(ContentType contentType)
Checks if the response contains a content type header with the specified value.
|
Response |
pipe(Response response)
Pipes response to another response and ends it.
|
default void |
redirect(java.lang.String url)
Redirects response to an url.
|
Request |
request()
Returns associated request of this response.
|
default Session |
session()
Returns current session.
|
default Response |
status(int statusCode)
Sets the response status code and default status message.
|
Response |
status(int statusCode,
java.lang.String statusMessage)
Sets the response status code and message.
|
int |
statusCode()
Returns status code.
|
java.lang.String |
statusMessage()
Returns status message.
|
default boolean |
succeeded()
Checks if response succeeded.
|
java.lang.String body()
Response body(byte[] body)
Response body(java.lang.Object body)
Response body(java.lang.String body)
Response body(java.lang.String body, ContentType contentType)
content-type.
Just a shortcut call.byte[] bodyBytes()
<T> java.util.List<T> bodyList(java.lang.Class<T> componentType)
body content.
If body is not set, returns null.<K,V> java.util.Map<K,V> bodyMap(java.lang.Class<K> keyType,
java.lang.Class<V> valueType)
body content.
If body is not set, returns null.default <V> java.util.Map<java.lang.String,V> bodyMap(java.lang.Class<V> valueType)
body content.
If body is not set, returns null.<T> T bodyValue()
body content.
If body is not set, returns null.<T> T bodyValue(java.lang.Class<T> type)
body content.
If body is not set, returns null.java.lang.String contentType()
Response contentType(ContentType contentType)
Context context()
java.util.Map<java.lang.String,Cookie> cookies()
Cookie cookie(java.lang.String name)
void end()
body(null).default void end(java.lang.Object body)
default void end(java.lang.String body)
default void end(java.lang.String body,
ContentType contentType)
content-type
and closes the response.java.lang.String header(java.lang.String name)
Response header(java.lang.String name, java.lang.String value)
MultiMap<java.lang.String> headers()
boolean isCommitted()
true if response is already committed.boolean isContentType(ContentType contentType)
default void redirect(java.lang.String url)
Request request()
default Session session()
default Response status(int statusCode)
Response status(int statusCode, java.lang.String statusMessage)
int statusCode()
java.lang.String statusMessage()
default boolean succeeded()