Interface HttpResult<T>

Type Parameters:
T - the type of a content which is to be converted into response body
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface
public interface HttpResult<T>
An interface which helps a user specify an HttpStatus or ResponseHeaders for a response produced by an annotated HTTP service method. The HTTP content can be specified as content as well, and it would be converted into response body by a ResponseConverterFunction.
  • Method Details

    • of

      static <T> HttpResult<T> of​(HttpHeaders headers)
      Creates a new HttpResult with the specified headers and without content.
      Parameters:
      headers - the HTTP headers
    • of

      static <T> HttpResult<T> of​(HttpHeaders headers, T content)
      Creates a new HttpResult with the specified headers and content.
      Parameters:
      headers - the HTTP headers
      content - the content of the response
    • of

      static <T> HttpResult<T> of​(HttpHeaders headers, T content, HttpHeaders trailers)
      Creates a new HttpResult with the specified headers, content and trailers.
      Parameters:
      headers - the HTTP headers
      content - the content of the response
      trailers - the HTTP trailers
    • of

      static <T> HttpResult<T> of​(HttpStatus status)
      Creates a new HttpResult with the specified HttpStatus and without content.
      Parameters:
      status - the HTTP status
    • of

      static <T> HttpResult<T> of​(HttpStatus status, T content)
      Creates a new HttpResult with the specified HttpStatus and content.
      Parameters:
      status - the HTTP status
      content - the content of the response
    • of

      static <T> HttpResult<T> of​(HttpStatus status, T content, HttpHeaders trailers)
      Creates a new HttpResult with the specified HttpStatus, content and trailers.
      Parameters:
      status - the HTTP status
      content - the content of the response
      trailers - the HTTP trailers
    • of

      static <T> HttpResult<T> of​(T content)
      Creates a new HttpResult with the specified content and the HttpStatus.OK status.
      Parameters:
      content - the content of the response
    • headers

      HttpHeaders headers()
      Returns the response HttpHeaders which may not contain the ":status" header. If the ":status" header does not exist, HttpStatus.OK or the status code specified in the StatusCode annotation will be used.
    • content

      @Nullable default T content()
      Returns an object which would be converted into response body.
      Returns:
      the response object, or null if the response object is not available.
    • trailers

      default HttpHeaders trailers()
      Returns the HTTP trailers of a response.