This repository has been archived on 2026-05-13. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
educode-controller/internal/api/server.go
2025-07-04 18:03:00 +08:00

35 lines
711 B
Go

package api
import (
"github.com/gin-gonic/gin"
"k8s.io/client-go/kubernetes"
)
// NewServer creates and configures a new Gin server.
func NewServer(clientset *kubernetes.Clientset) *gin.Engine {
r := gin.Default()
// Create a new handler with the clientset
h := NewHandler(clientset)
// Health check endpoint
r.GET("/healthz", func(c *gin.Context) {
c.JSON(200, gin.H{
"status": "ok",
})
})
v1 := r.Group("/api/v1")
{
workspaces := v1.Group("/workspaces")
{
workspaces.POST("", h.createWorkspace)
workspaces.DELETE("/:workspaceID", h.deleteWorkspace)
workspaces.GET("/:workspaceID", h.getWorkspace)
workspaces.PATCH("/:workspaceID", h.extendWorkspace)
}
}
return r
}