Search in sources :

Example 1 with ACTUATOR_V2_MEDIATYPE

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));
}
Also used : Collections.emptyMap(java.util.Collections.emptyMap) ClientResponse(org.springframework.web.reactive.function.client.ClientResponse) Logger(org.slf4j.Logger) ParameterizedTypeReference(org.springframework.core.ParameterizedTypeReference) MediaType(org.springframework.http.MediaType) InstanceId(de.codecentric.boot.admin.server.domain.values.InstanceId) LoggerFactory(org.slf4j.LoggerFactory) Endpoint(de.codecentric.boot.admin.server.domain.values.Endpoint) HashMap(java.util.HashMap) Mono(reactor.core.publisher.Mono) Level(java.util.logging.Level) LinkedHashMap(java.util.LinkedHashMap) Instance(de.codecentric.boot.admin.server.domain.entities.Instance) HttpStatus(org.springframework.http.HttpStatus) Map(java.util.Map) StatusInfo(de.codecentric.boot.admin.server.domain.values.StatusInfo) ACTUATOR_V2_MEDIATYPE(de.codecentric.boot.admin.server.utils.MediaType.ACTUATOR_V2_MEDIATYPE) InstanceWebClient(de.codecentric.boot.admin.server.web.client.InstanceWebClient) InstanceRepository(de.codecentric.boot.admin.server.domain.entities.InstanceRepository) StatusInfo(de.codecentric.boot.admin.server.domain.values.StatusInfo)

Aggregations

Instance (de.codecentric.boot.admin.server.domain.entities.Instance)1 InstanceRepository (de.codecentric.boot.admin.server.domain.entities.InstanceRepository)1 Endpoint (de.codecentric.boot.admin.server.domain.values.Endpoint)1 InstanceId (de.codecentric.boot.admin.server.domain.values.InstanceId)1 StatusInfo (de.codecentric.boot.admin.server.domain.values.StatusInfo)1 ACTUATOR_V2_MEDIATYPE (de.codecentric.boot.admin.server.utils.MediaType.ACTUATOR_V2_MEDIATYPE)1 InstanceWebClient (de.codecentric.boot.admin.server.web.client.InstanceWebClient)1 Collections.emptyMap (java.util.Collections.emptyMap)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 Level (java.util.logging.Level)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1 ParameterizedTypeReference (org.springframework.core.ParameterizedTypeReference)1 HttpStatus (org.springframework.http.HttpStatus)1 MediaType (org.springframework.http.MediaType)1 ClientResponse (org.springframework.web.reactive.function.client.ClientResponse)1 Mono (reactor.core.publisher.Mono)1