public interface ResponseBuilder
Responses.| Modifier and Type | Interface and Description |
|---|---|
static class |
ResponseBuilder.Factory
A factory creating ResponseBuilder instances.
|
| Modifier and Type | Method and Description |
|---|---|
static ResponseBuilder |
badRequest()
Creates a
ResponseBuilder with a "400 Bad Request" status. |
static ResponseBuilder |
badRequestJson(String json)
Creates a
ResponseBuilder with a "400 Bad Request" status, a Content-Type of
"application/json;charset=utf-8", and the provided body content. |
ResponseBuilder |
body(byte[] body)
Sets the
Response body with the provided message using UTF-8 encoding and updating the Content-Length
header appropriately. |
default ResponseBuilder |
body(String msg)
Sets the
Response body with the provided message using UTF-8 encoding and updating the Content-Length
header appropriately. |
ResponseBuilder |
body(String msg,
Charset charset)
|
Response |
build()
Creates the
Response. |
ResponseBuilder |
contentType(MediaType type)
Sets the Content-Type header field on the
Response. |
ResponseBuilder |
contentType(String type)
Sets the Content-Type header field on the
Response. |
static ResponseBuilder |
forbidden()
Creates a
ResponseBuilder with a "403 Forbidden" status. |
static ResponseBuilder |
found(String url)
Creates a
ResponseBuilder with a "302 Found" status. |
ResponseBuilder |
header(HeaderField headerField)
|
ResponseBuilder |
header(String headerName,
String headerValue)
Adds a
HeaderField to the Response. |
ResponseBuilder |
headers(Headers headers)
|
static ResponseBuilder |
internalServerError()
Creates a
ResponseBuilder with a "500 Internal Server Error" status. |
static ResponseBuilder |
newInstance(HttpStatus status)
Creates a ResponseBuilder.
|
static ResponseBuilder |
notFound()
Creates a
ResponseBuilder with a "404 Not Found" status and a Content Type of "text/html;charset=UTF-8". |
static ResponseBuilder |
notFoundJson()
Creates a
ResponseBuilder with a "404 Not Found" status and a content type of
"application/json;charset=UTF-8". |
static ResponseBuilder |
ok()
Creates a
ResponseBuilder with a "200 OK" status. |
static ResponseBuilder |
ok(String msg)
Creates a
ResponseBuilder with a "200 OK" status, a Content-Type of
"text/html;charset=UTF-8", and the provided string message as the Response body |
static ResponseBuilder |
serviceUnavailable()
Creates a
ResponseBuilder with a "503 Service Unavailable" status. |
static ResponseBuilder |
unauthorized()
Creates a
ResponseBuilder with a "401 Unauthorized" status. |
static ResponseBuilder |
unprocessableEntity()
Creates a
ResponseBuilder with a "422 Unprocessable Entity" status. |
ResponseBuilder body(String msg, Charset charset)
Response body with the provided message, encoding as bytes using the provided Charset
and updating the Content-Length header appropriately.msg - the body contentcharset - character set to use.ResponseBuilder instancedefault ResponseBuilder body(String msg)
Response body with the provided message using UTF-8 encoding and updating the Content-Length
header appropriately.msg - the body contentResponseBuilder instanceResponseBuilder body(byte[] body)
Response body with the provided message using UTF-8 encoding and updating the Content-Length
header appropriately.body - the body content. The specified array will be copied and not stored by this object.ResponseBuilder instanceResponseBuilder headers(Headers headers)
headers - the Headers object. The specified Headers object will be copied and not
stored by this object.ResponseBuilder instance.IllegalArgumentException - if the provided Headers object was not created by the provided
HeadersFactory. See ServiceFactory.headersFactory().ResponseBuilder header(HeaderField headerField)
headerField - the HeaderField. The specified HeaderField will be coped and not
stored by this object.ResponseBuilder instanceResponseBuilder header(String headerName, String headerValue)
HeaderField to the Response.headerName - the header nameheaderValue - the header valueResponseBuilder instanceResponseBuilder contentType(String type)
Response.type - the ContentType to add.ResponseBuilder instanceHeaders.setContentType(String)ResponseBuilder contentType(MediaType type)
Response.type - the ContentType to add.ResponseBuilder instanceHeaders.setContentType(MediaType)static ResponseBuilder newInstance(HttpStatus status)
status - the HttpStatus for the ResponseResponseBuilderstatic ResponseBuilder ok(String msg)
ResponseBuilder with a "200 OK" status, a Content-Type of
"text/html;charset=UTF-8", and the provided string message as the Response bodymsg - the body contentResponseBuilderstatic ResponseBuilder ok()
ResponseBuilder with a "200 OK" status.ResponseBuilderstatic ResponseBuilder unprocessableEntity()
ResponseBuilder with a "422 Unprocessable Entity" status.ResponseBuilderstatic ResponseBuilder badRequest()
ResponseBuilder with a "400 Bad Request" status.ResponseBuilderstatic ResponseBuilder badRequestJson(String json)
ResponseBuilder with a "400 Bad Request" status, a Content-Type of
"application/json;charset=utf-8", and the provided body content.json - The JSON body content.ResponseBuilderstatic ResponseBuilder serviceUnavailable()
ResponseBuilder with a "503 Service Unavailable" status.ResponseBuilderstatic ResponseBuilder internalServerError()
ResponseBuilder with a "500 Internal Server Error" status.ResponseBuilderstatic ResponseBuilder forbidden()
ResponseBuilder with a "403 Forbidden" status.ResponseBuilderstatic ResponseBuilder found(String url)
ResponseBuilder with a "302 Found" status.url - URL to redirect to.ResponseBuilderstatic ResponseBuilder notFound()
ResponseBuilder with a "404 Not Found" status and a Content Type of "text/html;charset=UTF-8".ResponseBuilderstatic ResponseBuilder notFoundJson()
ResponseBuilder with a "404 Not Found" status and a content type of
"application/json;charset=UTF-8".
The body is set to the JSON content:
{ "msg" : "not found" }
ResponseBuilderstatic ResponseBuilder unauthorized()
ResponseBuilder with a "401 Unauthorized" status.ResponseBuilderCopyright 2023 Ping Identity Corp. All rights reserved.