Align backend workbench API with prototype
This commit is contained in:
@@ -20,6 +20,7 @@ func (h *Handler) Register(router gin.IRouter) {
|
||||
router.POST("/projects", h.createProject)
|
||||
router.GET("/projects", h.listProjects)
|
||||
router.GET("/projects/:id/dashboard", h.dashboard)
|
||||
router.GET("/projects/:id/workspace", h.workspace)
|
||||
}
|
||||
|
||||
func (h *Handler) createProject(c *gin.Context) {
|
||||
@@ -76,3 +77,22 @@ func (h *Handler) dashboard(c *gin.Context) {
|
||||
}
|
||||
c.JSON(http.StatusOK, dashboard)
|
||||
}
|
||||
|
||||
func (h *Handler) workspace(c *gin.Context) {
|
||||
userID, ok := auth.CurrentUserID(c)
|
||||
if !ok {
|
||||
c.JSON(http.StatusUnauthorized, gin.H{"error": "missing current user"})
|
||||
return
|
||||
}
|
||||
projectID, err := strconv.ParseUint(c.Param("id"), 10, 64)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "invalid project id"})
|
||||
return
|
||||
}
|
||||
workspace, err := h.service.Workspace(userID, uint(projectID))
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "failed to load workspace"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, workspace)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user