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 { // choose a better status code if available c.JSON(http.StatusExpectationFailed, gin.H{ "message": "could not get node health status", }) return } c.JSON(http.StatusOK, gin.H{ "syncComplete": data.SyncComplete, "chainName": data.ChainName, }) } func metricsHandler(c *gin.Context) { c.JSON(http.StatusOK, gin.H{ "ok": true, }) }