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 and HttpHeaders 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 Detail

      • 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 trailingHeaders)
        Creates a new HttpResult with the specified headers, content and trailing headers.
        Parameters:
        headers - the HTTP headers
        content - the content of the response
        trailingHeaders - the trailing HTTP headers
      • 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 trailingHeaders)
        Creates a new HttpResult with the specified HttpStatus, content and trailing headers.
        Parameters:
        status - the HTTP status
        content - the content of the response
        trailingHeaders - the trailing HTTP headers
      • 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
      • content

        default Optional<T> content()
        Returns an object which would be converted into response body.