feat(servers): implement saervers monitoring

This commit is contained in:
2025-06-17 12:50:50 +03:00
parent 0e2e02622d
commit 42f2b68848
7 changed files with 217 additions and 5 deletions

View File

@@ -0,0 +1,22 @@
package api
import (
"encoding/json"
"net/http"
"gitea.mrixs.me/minecraft-platform/backend/internal/database"
)
type ServerHandler struct {
Repo *database.ServerRepository
}
func (h *ServerHandler) GetServers(w http.ResponseWriter, r *http.Request) {
servers, err := h.Repo.GetAllWithStatus(r.Context())
if err != nil {
http.Error(w, "Failed to get servers", http.StatusInternalServerError)
return
}
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(servers)
}