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.
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 Summary
Modifier and TypeMethodDescriptiondefault T
content()
Returns an object which would be converted into response body.headers()
Returns the responseHttpHeaders
which may not contain the":status"
header.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 trailers)
Creates a newHttpResult
with the specified headers, content and trailers.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 trailers)
Creates a newHttpResult
with the specifiedHttpStatus
, content and trailers.static <T> HttpResult<T>
of(T content)
Creates a newHttpResult
with the specified content and theHttpStatus.OK
status.default HttpHeaders
trailers()
Returns the HTTP trailers of a response.
-
Method Details
-
of
Creates a newHttpResult
with the specified headers and without content.- Parameters:
headers
- the HTTP headers
-
of
Creates a newHttpResult
with the specified headers and content.- Parameters:
headers
- the HTTP headerscontent
- the content of the response
-
of
Creates a newHttpResult
with the specified headers, content and trailers.- Parameters:
headers
- the HTTP headerscontent
- the content of the responsetrailers
- the HTTP trailers
-
of
Creates a newHttpResult
with the specifiedHttpStatus
and without content.- Parameters:
status
- the HTTP status
-
of
Creates a newHttpResult
with the specifiedHttpStatus
and content.- Parameters:
status
- the HTTP statuscontent
- the content of the response
-
of
Creates a newHttpResult
with the specifiedHttpStatus
, content and trailers.- Parameters:
status
- the HTTP statuscontent
- the content of the responsetrailers
- the HTTP trailers
-
of
Creates a newHttpResult
with the specified content and theHttpStatus.OK
status.- Parameters:
content
- the content of the response
-
headers
HttpHeaders headers()Returns the responseHttpHeaders
which may not contain the":status"
header. If the":status"
header does not exist,HttpStatus.OK
or the status code specified in theStatusCode
annotation will be used. -
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
Returns the HTTP trailers of a response.
-