All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.groupbyinc.common.web.mvc.health.AbstractHealthController Maven / Gradle / Ivy

The newest version!
package com.groupbyinc.common.web.mvc.health;

import com.groupbyinc.common.manager.health.HealthStatus;
import com.groupbyinc.common.manager.health.HealthStatusResponse;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

import static org.springframework.http.HttpStatus.OK;
import static org.springframework.http.HttpStatus.SERVICE_UNAVAILABLE;

/**
 * Abstract health controller
 *
 * @author Osman Currim
 * @author Alan Czajkowski
 */
public abstract class AbstractHealthController {

    public abstract ResponseEntity checkStatus();

    protected HttpStatus getHttpStatus(HealthStatus status) {
        HttpStatus httpStatus;

        switch (status) {
        case green:
        case yellow:
            httpStatus = OK;
            break;
        case red:
        default:
            httpStatus = SERVICE_UNAVAILABLE;
            break;
        }

        return httpStatus;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy