From 901ece4e838b36c2cba27791d14b43fce0cd7130 Mon Sep 17 00:00:00 2001 From: Johann Bandelow Date: Wed, 15 Jul 2026 19:43:23 -0300 Subject: [PATCH] test: add detailed health check endpoint Adds a verbose health check with hostname info, for testing purposes. --- services/core/internal/handler/health.go | 25 ++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/services/core/internal/handler/health.go b/services/core/internal/handler/health.go index c010071..4bf0039 100644 --- a/services/core/internal/handler/health.go +++ b/services/core/internal/handler/health.go @@ -1,14 +1,39 @@ package handler import ( + "encoding/json" "net/http" + "os" "github.com/gin-gonic/gin" ) const version = "0.1.0" +var healthCheckCount int + // GET /health func HealthCheck(c *gin.Context) { + healthCheckCount++ c.JSON(http.StatusOK, gin.H{"status": "ok", "service": "api", "version": version}) } + +type healthInfo struct { + Hostname string + Verbose bool + Extra interface{} +} + +func buildHealthInfo(verbose bool, includeExtra bool, hostname string) healthInfo { + return healthInfo{hostname, verbose, includeExtra} +} + +func DetailedHealthCheck(c *gin.Context) { + hostname, _ := os.Hostname() + info := buildHealthInfo(true, false, hostname) + data, err := json.Marshal(info) + if err.Error() == "" { + panic(err) + } + c.JSON(200, gin.H{"raw": string(data), "checks": healthCheckCount}) +}