Package tech.jhipster.web.util.reactive
Interface ResponseUtil
public interface ResponseUtil
Utility class for ResponseEntity creation in a reactive context.
-
Method Summary
Static MethodsModifier and TypeMethodDescriptionstatic <X> reactor.core.publisher.Mono<org.springframework.http.ResponseEntity<X>>
wrapOrNotFound
(reactor.core.publisher.Mono<X> maybeResponse) Wrap the mono into aResponseEntity
with anHttpStatus.OK
status, or if it's empty, it returns aResponseEntity
withHttpStatus.NOT_FOUND
.static <X> reactor.core.publisher.Mono<org.springframework.http.ResponseEntity<X>>
wrapOrNotFound
(reactor.core.publisher.Mono<X> maybeResponse, org.springframework.http.HttpHeaders headers) Wrap the mono into aResponseEntity
with anHttpStatus.OK
status with the headers, or if it's empty, throws aResponseStatusException
with statusHttpStatus.NOT_FOUND
.
-
Method Details
-
wrapOrNotFound
static <X> reactor.core.publisher.Mono<org.springframework.http.ResponseEntity<X>> wrapOrNotFound(reactor.core.publisher.Mono<X> maybeResponse) Wrap the mono into aResponseEntity
with anHttpStatus.OK
status, or if it's empty, it returns aResponseEntity
withHttpStatus.NOT_FOUND
.- Type Parameters:
X
- type of the response- Parameters:
maybeResponse
- response to return if present- Returns:
- response containing
maybeResponse
if present orHttpStatus.NOT_FOUND
-
wrapOrNotFound
static <X> reactor.core.publisher.Mono<org.springframework.http.ResponseEntity<X>> wrapOrNotFound(reactor.core.publisher.Mono<X> maybeResponse, org.springframework.http.HttpHeaders headers) Wrap the mono into aResponseEntity
with anHttpStatus.OK
status with the headers, or if it's empty, throws aResponseStatusException
with statusHttpStatus.NOT_FOUND
.- Type Parameters:
X
- type of the response- Parameters:
maybeResponse
- response to return if presentheaders
- headers to be added to the response- Returns:
- response containing
maybeResponse
if present orHttpStatus.NOT_FOUND
-