com.groupbyinc.common.web.mvc.health.AbstractHealthController Maven / Gradle / Ivy
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(String customerId);
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;
}
}