class StatusResource {

  @Timed @ExceptionMetered
  @GET
  public Response get() {
    SortedMap<String, HealthCheck.Result> results = memoizedCheck.get();

    List<String> failing = results.entrySet().stream()
        .filter(r -> !r.getValue().isHealthy())
        .map(Map.Entry::getKey)
        .collect(toList());

    if (!failing.isEmpty()) {
      logger.warn("Health checks failed: {}", results);
      String message = "failing health checks: " + Arrays.toString(failing.toArray());
      StatusResponse sr = new StatusResponse("critical", message, results);
      return Response.serverError().entity(sr).build();
    }
    StatusResponse sr = new StatusResponse("ok", "ok", results);
    return Response.ok(sr).build();
  }

  @Inject public  StatusResource(KeywhizConfig keywhizConfig, Environment environment);

}