public class ResponseBuilder
Builder for building custom responses.
Response builders are used in cases where the response headers or status need to be changed from the defaults. This happens when the response is a success but the status is not 200 (OK). For example, 201 (created) or 202 (accepted).
It is also necessary to use a builder to change any of the headers, for example if the content type is not the default.
| Modifier and Type | Method and Description |
|---|---|
Response |
build(java.lang.Object body)
Builds a response from the data in this builder.
|
java.util.Map<java.lang.String,java.lang.String> |
getHeaders() |
ResponseBuilder |
header(java.lang.String name,
java.lang.String value)
Sets the value of the named header and returns this builder.
|
ResponseBuilder |
status(int status)
Sets the status code of the response and returns this builder.
|
public ResponseBuilder header(java.lang.String name, java.lang.String value)
Sets the value of the named header and returns this builder.
public ResponseBuilder status(int status)
Sets the status code of the response and returns this builder.
public Response build(java.lang.Object body)
Builds a response from the data in this builder.
public java.util.Map<java.lang.String,java.lang.String> getHeaders()