35 lines
711 B
Go
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
|
|
}
|