Add workspace creation feature
This commit is contained in:
34
internal/api/server.go
Normal file
34
internal/api/server.go
Normal file
@@ -0,0 +1,34 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user