(state: &HealthState)
| 93 | } |
| 94 | |
| 95 | fn render_response(state: &HealthState) -> (StatusCode, Json<HealthResponse>) { |
| 96 | let database = render_database(state); |
| 97 | let healthy = state.is_healthy(); |
| 98 | let response = HealthResponse { |
| 99 | status: if healthy { |
| 100 | STATUS_HEALTHY |
| 101 | } else { |
| 102 | STATUS_UNHEALTHY |
| 103 | }, |
| 104 | version: openshell_core::VERSION, |
| 105 | checks: HealthChecks { database }, |
| 106 | }; |
| 107 | let code = if healthy { |
| 108 | StatusCode::OK |
| 109 | } else { |
| 110 | StatusCode::SERVICE_UNAVAILABLE |
| 111 | }; |
| 112 | (code, Json(response)) |
| 113 | } |
| 114 | |
| 115 | fn render_database(state: &HealthState) -> DependencyCheck { |
| 116 | match state { |
no test coverage detected