1 package lv.id.jc.piglatin.actuator;
2
3 import java.util.function.IntFunction;
4
5 import org.springframework.boot.actuate.health.Health;
6 import org.springframework.http.HttpStatus;
7 import org.springframework.stereotype.Component;
8
9
10 @Component
11 public class HealthFunction implements IntFunction<Health> {
12
13
14
15
16
17
18
19 @Override
20 public Health apply(int statusCode) {
21 if (statusCode == HttpStatus.OK.value()) {
22 return Health.up().build();
23 }
24 return Health.down()
25 .withDetail("HTTP Status Code", statusCode)
26 .build();
27 }
28 }