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 anHttpStatus
andHttpHeaders
for a response produced by an annotated HTTP service method. The HTTP content can be specified ascontent
as well, and it would be converted into response body by aResponseConverterFunction
.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default Optional<T>
content()
Returns an object which would be converted into response body.HttpHeaders
headers()
ReturnsHttpHeaders
of a response.static <T> HttpResult<T>
of(HttpHeaders headers)
Creates a newHttpResult
with the specified headers and without content.static <T> HttpResult<T>
of(HttpHeaders headers, T content)
Creates a newHttpResult
with the specified headers and content.static <T> HttpResult<T>
of(HttpHeaders headers, T content, HttpHeaders trailingHeaders)
Creates a newHttpResult
with the specified headers, content and trailing headers.static <T> HttpResult<T>
of(HttpStatus status)
Creates a newHttpResult
with the specifiedHttpStatus
and without content.static <T> HttpResult<T>
of(HttpStatus status, T content)
Creates a newHttpResult
with the specifiedHttpStatus
and content.static <T> HttpResult<T>
of(HttpStatus status, T content, HttpHeaders trailingHeaders)
Creates a newHttpResult
with the specifiedHttpStatus
, content and trailing headers.static <T> HttpResult<T>
of(T content)
Creates a newHttpResult
with the specified content and theHttpStatus.OK
status.default HttpHeaders
trailingHeaders()
Returns trailingHttpHeaders
of a response.
-
-
-
Method Detail
-
of
static <T> HttpResult<T> of(HttpHeaders headers)
Creates a newHttpResult
with the specified headers and without content.- Parameters:
headers
- the HTTP headers
-
of
static <T> HttpResult<T> of(HttpHeaders headers, T content)
Creates a newHttpResult
with the specified headers and content.- Parameters:
headers
- the HTTP headerscontent
- the content of the response
-
of
static <T> HttpResult<T> of(HttpHeaders headers, T content, HttpHeaders trailingHeaders)
Creates a newHttpResult
with the specified headers, content and trailing headers.- Parameters:
headers
- the HTTP headerscontent
- the content of the responsetrailingHeaders
- the trailing HTTP headers
-
of
static <T> HttpResult<T> of(HttpStatus status)
Creates a newHttpResult
with the specifiedHttpStatus
and without content.- Parameters:
status
- the HTTP status
-
of
static <T> HttpResult<T> of(HttpStatus status, T content)
Creates a newHttpResult
with the specifiedHttpStatus
and content.- Parameters:
status
- the HTTP statuscontent
- the content of the response
-
of
static <T> HttpResult<T> of(HttpStatus status, T content, HttpHeaders trailingHeaders)
Creates a newHttpResult
with the specifiedHttpStatus
, content and trailing headers.- Parameters:
status
- the HTTP statuscontent
- the content of the responsetrailingHeaders
- the trailing HTTP headers
-
of
static <T> HttpResult<T> of(T content)
Creates a newHttpResult
with the specified content and theHttpStatus.OK
status.- Parameters:
content
- the content of the response
-
headers
HttpHeaders headers()
ReturnsHttpHeaders
of a response.
-
content
default Optional<T> content()
Returns an object which would be converted into response body.
-
trailingHeaders
default HttpHeaders trailingHeaders()
Returns trailingHttpHeaders
of a response.
-
-