add access token validation logic and some media stuff

This commit is contained in:
wisplite
2025-11-22 19:51:26 -06:00
parent a78003b5a3
commit fe849f558c
6 changed files with 116 additions and 1 deletions
+18
View File
@@ -17,4 +17,22 @@ func RegisterAlbumRoutes(rg *gin.RouterGroup) {
}
c.JSON(http.StatusOK, albums)
})
album.POST("/createAlbum", func(c *gin.Context) {
accessToken := c.GetHeader("Authorization")
if accessToken == "" {
c.JSON(http.StatusUnauthorized, gin.H{"error": "Unauthorized"})
return
}
var request struct {
Title string `json:"title"`
Description string `json:"description"`
ParentID string `json:"parentId"`
}
result, err := services.CreateAlbum(accessToken, request.Title, request.Description, request.ParentID)
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
c.JSON(http.StatusOK, result)
})
}