use of de.codecentric.boot.admin.server.utils.MediaType.ACTUATOR_V2_MEDIATYPE in project spring-boot-admin by codecentric.
the class StatusUpdater method convertStatusInfo.
protected Mono<StatusInfo> convertStatusInfo(ClientResponse response) {
Boolean hasCompatibleContentType = response.headers().contentType().map((mt) -> mt.isCompatibleWith(MediaType.APPLICATION_JSON) || mt.isCompatibleWith(ACTUATOR_V2_MEDIATYPE)).orElse(false);
StatusInfo statusInfoFromStatus = this.getStatusInfoFromStatus(response.statusCode(), emptyMap());
if (hasCompatibleContentType) {
return response.bodyToMono(RESPONSE_TYPE).map((body) -> {
if (body.get("status") instanceof String) {
return StatusInfo.from(body);
}
return getStatusInfoFromStatus(response.statusCode(), body);
}).defaultIfEmpty(statusInfoFromStatus);
}
return response.releaseBody().then(Mono.just(statusInfoFromStatus));
}
Aggregations