public interface ResponseBuilder
| Modifier and Type | Field and Description |
|---|---|
static com.google.gson.Gson |
gson |
| Modifier and Type | Method and Description |
|---|---|
default Response |
AcceptedResponse()
Creates an empty response with only 202 - Accepted
|
default Response |
CreatedResponse()
Creates an empty response with only 201 - Created
|
default Response |
EmptyResponse(int responseCode)
Creates an empty response with only a response code
|
default Response |
ErrorResponse(int responseCode,
String message)
Creates an error with a provided error code
|
default Response |
ErrorResponse(Throwable throwable)
Creates an error response with a internal error code.
|
default Response |
ErrorResponseMissingPath()
Creates an error with code 400 and the message that the path is missing
|
default Response |
ErrorResponseNotFound(String message)
Creates an error with a 404 - Not found
|
default Response |
ErrorResponseResourceAlreadyExists(String path)
Creates an error with code 403 and the message that the path already exists.
|
default Response |
ErrorResponseUnsupportedOperation()
Creates an error with code 405 stating the operation is not supported.
|
default Response |
ObjectResponse(Object object)
Creates a response where the provided object will be converted to json.
|
default Response |
ObjectResponse(Object object,
String charEncoding)
Creates a response where the provided object will be converted to json.
|
default void |
writeResponse(javax.servlet.http.HttpServletResponse resp,
Response response)
Write the response to the client.
|
default void |
writeResponse(javax.servlet.http.HttpServletResponse resp,
Try<Response> response)
Write the response to the client.
|
default Response EmptyResponse(int responseCode)
responseCode - The HTTP response codedefault Response AcceptedResponse()
default Response CreatedResponse()
default Response ObjectResponse(Object object)
object - The response object/messagedefault Response ObjectResponse(Object object, String charEncoding)
object - The response object/messagecharEncoding - The character encoding to usedefault Response ErrorResponse(Throwable throwable)
throwable - The underlying issueErrorResponse(int, String)default Response ErrorResponse(int responseCode, String message)
responseCode - The HTTP response codemessage - The messagedefault Response ErrorResponseNotFound(String message)
message - The messagedefault Response ErrorResponseMissingPath()
default Response ErrorResponseResourceAlreadyExists(String path)
path - The path which already existeddefault Response ErrorResponseUnsupportedOperation()
default void writeResponse(javax.servlet.http.HttpServletResponse resp,
Try<Response> response)
throws IOException
resp - The HTTP servlet response objectresponse - The response object, either successful or failedIOExceptiondefault void writeResponse(javax.servlet.http.HttpServletResponse resp,
Response response)
throws IOException
resp - The HTTP servlet response objectresponse - The response object to be sent to the clientIOExceptionCopyright © 2016, Peter Nerg Apache License v2.0