/** * This is a Sixt-specific implementation. */ @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { Collection<HealthCheck> healthChecks = healthManager.getCurrentHealthChecks(); HealthCheck.Status summary = healthManager.getSummaryFor(healthChecks); JsonObject json = new JsonObject(); json.addProperty("summary", translateStatus(summary)); if (! healthChecks.isEmpty()) { JsonArray detailsArray = new JsonArray(); for (HealthCheck check : healthChecks) { detailsArray.add(getCheckDetail(check)); } json.add("details", detailsArray); } resp.getWriter().print(json.toString()); }
private JsonObject getCheckDetail(HealthCheck check) { JsonObject retval = new JsonObject(); retval.add("name", new JsonPrimitive(check.getName())); retval.add("status", new JsonPrimitive(translateStatus(check.getStatus()))); String message = check.getMessage(); retval.add("reason", new JsonPrimitive(message == null ? "" : message)); return retval; }