feat(servers): implement saervers monitoring

This commit is contained in:
Mrixs committed 2025-06-17 12:50:50 +03:00
1 parent 0e2e02622d
commit 42f2b68848
7 files changed
+217 -5

No files matched your search

+22
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)
}