Backend: API handlers, WebSocket manager, K8s client, CRDT, auth
This commit is contained in:
26
server/internal/api/handlers/cluster.go
Normal file
26
server/internal/api/handlers/cluster.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type ClusterInfo struct {
|
||||
Name string `json:"name"`
|
||||
Version string `json:"version"`
|
||||
Health bool `json:"health"`
|
||||
ServerURL string `json:"server_url"`
|
||||
}
|
||||
|
||||
func ClusterHandler(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
cluster := ClusterInfo{
|
||||
Name: "local",
|
||||
Version: "v1.29.0",
|
||||
Health: true,
|
||||
ServerURL: "https://kubernetes.default.svc",
|
||||
}
|
||||
|
||||
json.NewEncoder(w).Encode(cluster)
|
||||
}
|
||||
15
server/internal/api/handlers/health.go
Normal file
15
server/internal/api/handlers/health.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type HealthResponse struct {
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
func HealthHandler(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(HealthResponse{Status: "ok"})
|
||||
}
|
||||
14
server/internal/api/handlers/namespaces.go
Normal file
14
server/internal/api/handlers/namespaces.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func NamespacesHandler(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
namespaces := []string{"default", "kube-system", "kube-public"}
|
||||
|
||||
json.NewEncoder(w).Encode(namespaces)
|
||||
}
|
||||
47
server/internal/api/handlers/resources.go
Normal file
47
server/internal/api/handlers/resources.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type ResourceResponse struct {
|
||||
Kind string `json:"kind"`
|
||||
Name string `json:"name"`
|
||||
Namespace string `json:"namespace"`
|
||||
UID string `json:"uid"`
|
||||
Labels map[string]string `json:"labels,omitempty"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
}
|
||||
|
||||
func ResourcesHandler(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
// Placeholder - will be implemented with actual K8s client
|
||||
resources := []ResourceResponse{
|
||||
{
|
||||
Kind: "Namespace",
|
||||
Name: "default",
|
||||
Namespace: "",
|
||||
UID: "ns-default",
|
||||
CreatedAt: "2024-01-01T00:00:00Z",
|
||||
},
|
||||
}
|
||||
|
||||
json.NewEncoder(w).Encode(resources)
|
||||
}
|
||||
|
||||
func ResourceHandler(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
// Placeholder - will be implemented with actual K8s client
|
||||
resource := ResourceResponse{
|
||||
Kind: "Pod",
|
||||
Name: "example-pod",
|
||||
Namespace: "default",
|
||||
UID: "pod-example",
|
||||
CreatedAt: "2024-01-01T00:00:00Z",
|
||||
}
|
||||
|
||||
json.NewEncoder(w).Encode(resource)
|
||||
}
|
||||
Reference in New Issue
Block a user