feat: scaffold codespace backend

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
tao.chen
2026-07-02 15:07:54 +08:00
co-authored by Claude Fable 5
commit 411ed1f8ba
43 changed files with 4428 additions and 0 deletions
+55
View File
@@ -0,0 +1,55 @@
package api
import (
"net/http"
"codespace/internal/model"
"codespace/internal/service"
"github.com/gin-gonic/gin"
)
type processHandler struct {
svc *service.ProcessService
}
func (h *processHandler) start(c *gin.Context) {
id := c.Param("id")
if err := h.svc.Start(id); err != nil {
writeError(c, err)
return
}
c.Status(http.StatusNoContent)
}
func (h *processHandler) stop(c *gin.Context) {
id := c.Param("id")
if err := h.svc.Stop(id); err != nil {
writeError(c, err)
return
}
c.Status(http.StatusNoContent)
}
func (h *processHandler) restart(c *gin.Context) {
id := c.Param("id")
if err := h.svc.Restart(id); err != nil {
writeError(c, err)
return
}
c.Status(http.StatusNoContent)
}
func (h *processHandler) status(c *gin.Context) {
id := c.Param("id")
status, err := h.svc.Status(id)
if err != nil {
writeError(c, err)
return
}
c.JSON(http.StatusOK, model.ProcessStatusResponse{
WorkspaceID: status.WorkspaceID,
Running: status.Running,
PID: status.PID,
})
}