package server import ( "fmt" "net/http" "github.com/gin-gonic/gin" ) func Start(port string, ginMode string) error { gin.SetMode(ginMode) gin.DisableConsoleColor() router := gin.Default() router.GET("/metrics", metricsHandler) router.GET("/health", healthHandler) return router.Run(port) } func healthHandler(c *gin.Context) { allOk, data := batchCall() fmt.Println(data.SyncComplete) if !allOk { c.JSON(http.StatusExpectationFailed, gin.H{ "ok": false, "message": "could not get node health status", }) return } c.JSON(http.StatusOK, gin.H{ "ok": true, "syncComplete": data.SyncComplete, "chainName": data.ChainName, }) } func metricsHandler(c *gin.Context) { c.JSON(http.StatusOK, gin.H{ "ok": true, }) }