Package io.micronaut.http
Interface HttpResponseFactory
-
- All Known Implementing Classes:
SimpleHttpResponseFactory
public interface HttpResponseFactory
A factory interface for creatingMutableHttpResponse
instances.- Since:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description static HttpResponseFactory
INSTANCE
The defaultHttpResponseFactory
instance.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default <T> MutableHttpResponse<T>
ok()
<T> MutableHttpResponse<T>
ok(T body)
Creates anHttpStatus.OK
response with a body.default <T> MutableHttpResponse<T>
status(HttpStatus status)
<T> MutableHttpResponse<T>
status(HttpStatus status, java.lang.String reason)
Return a response for the given status.<T> MutableHttpResponse<T>
status(HttpStatus status, T body)
Return a response for the given status.
-
-
-
Field Detail
-
INSTANCE
static final HttpResponseFactory INSTANCE
The defaultHttpResponseFactory
instance.
-
-
Method Detail
-
ok
<T> MutableHttpResponse<T> ok(T body)
Creates anHttpStatus.OK
response with a body.- Type Parameters:
T
- The body type- Parameters:
body
- The body- Returns:
- The ok response with the given body
-
status
<T> MutableHttpResponse<T> status(HttpStatus status, java.lang.String reason)
Return a response for the given status.- Type Parameters:
T
- The response type- Parameters:
status
- The statusreason
- An alternatively reason message- Returns:
- The response
-
status
<T> MutableHttpResponse<T> status(HttpStatus status, T body)
Return a response for the given status.- Type Parameters:
T
- The body type- Parameters:
status
- The statusbody
- The body- Returns:
- The response
-
ok
default <T> MutableHttpResponse<T> ok()
- Type Parameters:
T
- The response type- Returns:
- The ok response
-
status
default <T> MutableHttpResponse<T> status(HttpStatus status)
- Type Parameters:
T
- The response type- Parameters:
status
- The status- Returns:
- The restus response
-
-