Class Response<T>

    • Constructor Detail

      • Response

        public Response()
    • Method Detail

      • ok

        public static <T> Response<T> ok​(T value)
        HTTP 200 OK: pointless wrapper for type safety.
      • withMustRevalidate

        public static <T> Response<T> withMustRevalidate​(T value)
      • created

        public static <T> Response<T> created​(T value)
        HTTP 201 Created: typically used when a new resource is made.
      • accepted

        public static Response.Accepted accepted​(String location)
        HTTP 202 Accepted: accepted as background task.
      • none

        public static <T> Response<T> none()
        HTTP 204 No Content: typically used when the resource is deleted.
      • redirect

        public static Response.Redirect redirect​(String location)
        HTTP 302 Found: temporary redirect to another URL.
      • internalServerError

        public static <T> Response.InternalServerError<T> internalServerError​(Exception cause)
        HTTP 500 Internal Server Error: failure due to an unexpected exception.

        Can be returned from REST endpoints, instead of throwing the exception, if additional properties (e.g. a traceId) should be set on the response.

        Parameters:
        cause - the exception that caused the request to fail, must not be a RestApiException because such an exception would result in a 4XX response code
      • withStatusCode

        public static <T> Response<T> withStatusCode​(int statusCode,
                                                     T value)
        Arbitrary status code with wrapped result.
      • isNone

        public abstract boolean isNone()
      • statusCode

        public abstract int statusCode()