refactor(backend): isolate workspace aggregation
This commit is contained in:
@@ -140,14 +140,13 @@ func (h *Handler) workspace(c *gin.Context) {
|
||||
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"})
|
||||
projectIdentity, ok := httpx.IdentityParam(c, "id")
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
workspace, err := h.service.Workspace(userID, uint(projectID))
|
||||
workspace, err := h.service.Workspace(userID, projectIdentity)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "failed to load workspace"})
|
||||
writeProjectError(c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, workspace)
|
||||
|
||||
Reference in New Issue
Block a user