Class Response
Your application's ResponseMarshaler
is responsible for taking the Response
returned by a Resource Method as input
and creating a finalized binary representation (MarshaledResponse
), suitable for sending to clients over the wire.
Full documentation is available at https://www.soklet.com/docs/response-writing.
- Author:
- Mark Allen
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Builder used to construct instances ofResponse
viawithStatusCode(Integer)
orwithRedirect(RedirectType, String)
.static class
-
Method Summary
Modifier and TypeMethodDescriptioncopy()
Vends a mutable copier seeded with this instance's data, suitable for building new instances.boolean
getBody()
The "logical" body content to be written to the response, if present.The cookies to be written to the client for this response.The headers to be written to the client for this response.The HTTP status code to be written to the client for this response.int
hashCode()
toString()
static Response.Builder
withRedirect
(RedirectType redirectType, String location) Acquires a builder forResponse
instances that are intended to redirect the client.static Response.Builder
withStatusCode
(Integer statusCode) Acquires a builder forResponse
instances.
-
Method Details
-
withStatusCode
Acquires a builder forResponse
instances.- Parameters:
statusCode
- the HTTP status code for this request (200, 201, etc.
)- Returns:
- the builder
-
withRedirect
@Nonnull public static Response.Builder withRedirect(@Nonnull RedirectType redirectType, @Nonnull String location) Acquires a builder forResponse
instances that are intended to redirect the client.- Parameters:
redirectType
- the kind of redirect to perform, for exampleRedirectType.HTTP_307_TEMPORARY_REDIRECT
location
- the URL to redirect to- Returns:
- the builder
-
toString
-
equals
-
hashCode
-
copy
Vends a mutable copier seeded with this instance's data, suitable for building new instances.- Returns:
- a copier for this instance
-
getStatusCode
The HTTP status code to be written to the client for this response.See
StatusCode
for an enumeration of all HTTP status codes.- Returns:
- the HTTP status code to write to the response
-
getCookies
The cookies to be written to the client for this response.It is possible to send multiple
ResponseCookie
values with the same name to the client.Note that
ResponseCookie
values, like all response headers, have case-insensitive names per the HTTP spec.- Returns:
- the cookies to write to the response
-
getHeaders
The headers to be written to the client for this response.The keys are the header names and the values are header values (it is possible to send the client multiple headers with the same name).
Note that response headers have case-insensitive names per the HTTP spec.
- Returns:
- the headers to write to the response
-
getBody
The "logical" body content to be written to the response, if present.It is the responsibility of the
ResponseMarshaler
to take this object and convert it into bytes to send over the wire.- Returns:
- the object representing the response body, or
Optional.empty()
if no response body should be written
-