refactor: impl health checks, graceful shutdown & structured logging

This commit is contained in:
2026-01-04 15:06:35 +03:00
parent 192ec80010
commit 0751ddb88a
3 changed files with 71 additions and 24 deletions

View File

@@ -3,7 +3,7 @@ package api
import (
"encoding/json"
"errors"
"log"
"log/slog"
"net/http"
"gitea.mrixs.me/minecraft-platform/backend/internal/core"
@@ -40,7 +40,7 @@ func (h *AuthHandler) Authenticate(w http.ResponseWriter, r *http.Request) {
}
// Другие ошибки - внутренние
log.Printf("internal server error during authentication: %v", err)
slog.Error("internal server error during authentication", "error", err)
http.Error(w, "Internal server error", http.StatusInternalServerError)
return
}
@@ -69,7 +69,7 @@ func (h *AuthHandler) Join(w http.ResponseWriter, r *http.Request) {
return
}
log.Printf("internal server error during join: %v", err)
slog.Error("internal server error during join", "error", err)
http.Error(w, "Internal server error", http.StatusInternalServerError)
return
}
@@ -90,7 +90,7 @@ func (h *AuthHandler) Login(w http.ResponseWriter, r *http.Request) {
http.Error(w, "Invalid username or password", http.StatusUnauthorized)
return
}
log.Printf("internal server error during login: %v", err)
slog.Error("internal server error during login", "error", err)
http.Error(w, "Internal server error", http.StatusInternalServerError)
return
}