mirror of
https://github.com/Dvorinka/MyClubServer.git
synced 2026-06-05 03:02:56 +00:00
hot fix #1
This commit is contained in:
@@ -3,9 +3,11 @@ package controllers
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"os"
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
"fotbal-club/internal/config"
|
||||
"fotbal-club/internal/services"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -22,6 +24,8 @@ type HealthResponse struct {
|
||||
Status string `json:"status"`
|
||||
Timestamp time.Time `json:"timestamp"`
|
||||
Version string `json:"version,omitempty"`
|
||||
Env string `json:"env,omitempty"`
|
||||
Premium bool `json:"premium,omitempty"`
|
||||
Checks map[string]CheckResult `json:"checks"`
|
||||
System SystemInfo `json:"system,omitempty"`
|
||||
}
|
||||
@@ -100,6 +104,17 @@ func (hc *HealthController) Health(c *gin.Context) {
|
||||
ctx, cancel := context.WithTimeout(c.Request.Context(), 10*time.Second)
|
||||
defer cancel()
|
||||
|
||||
env := ""
|
||||
premium := false
|
||||
if config.AppConfig != nil {
|
||||
env = config.AppConfig.AppEnv
|
||||
premium = config.AppConfig.Premium
|
||||
}
|
||||
version := os.Getenv("APP_VERSION")
|
||||
if version == "" {
|
||||
version = "dev"
|
||||
}
|
||||
|
||||
checks := make(map[string]CheckResult)
|
||||
overallStatus := "healthy"
|
||||
|
||||
@@ -122,7 +137,9 @@ func (hc *HealthController) Health(c *gin.Context) {
|
||||
response := HealthResponse{
|
||||
Status: overallStatus,
|
||||
Timestamp: time.Now(),
|
||||
Version: "1.0.0", // Use actual version
|
||||
Version: version, // Use actual version
|
||||
Env: env,
|
||||
Premium: premium,
|
||||
Checks: checks,
|
||||
System: sysInfo,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user