package org.gluu.oxtrust.ws.rs.controller;

import javax.enterprise.context.ApplicationScoped;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

/**
 * Health check controller
 * 
 * @author Yuriy Movchan
 * @version Jul 24, 2020
 */
@ApplicationScoped
@Path("/")
public class HealthCheckController {

	@GET
	@POST
	@Path("/health-check")
	@Produces(MediaType.APPLICATION_JSON)
	public String healthCheckController() {
		return "{\"status\":\"running\"}";
	}

}

@@ -88,16 +88,44 @@
 Scoped;%0A
+import javax.inject.Inject;%0A
 import j
@@ -140,16 +140,16 @@
 rs.GET;%0A
-
 import j
@@ -255,16 +255,66 @@
 aType;%0A%0A
+import org.gluu.persist.PersistenceEntryManager;%0A%0A
 /**%0A * H
@@ -462,16 +462,84 @@
 ller %7B%0A%0A
+%09@Inject%0A%09private PersistenceEntryManager persistenceEntryManager;%0A%0A
 %09@GET%0A%09@
@@ -651,10 +651,164 @@
 ) %7B%0A
-%09%09
+    %09boolean isConnected = persistenceEntryManager.getOperationService().isConnected();%0A    %09String dbStatus = isConnected ? %22online%22 : %22offline%22; %0A        
 retu
@@ -823,16 +823,17 @@
 tatus%5C%22:
+ 
 %5C%22runnin
@@ -835,16 +835,52 @@
 unning%5C%22
+, %5C%22db_status%5C%22:%5C%22%22 + dbStatus + %22%5C%22
 %7D%22;%0A%09%7D%0A%0A

Improve health check