refactor: impl health checks, graceful shutdown & structured logging
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user