adding spotify api interaction

This commit is contained in:
2025-11-20 18:04:31 +00:00
parent 10b5dfabfd
commit 9aabff9752
4 changed files with 26 additions and 4 deletions

View File

@@ -13,7 +13,7 @@ type CreatePostInput struct {
Author string `json:"author" binding:"required"`
}
func (h *Handler) GetPosts(c *gin.Context) {
func (h *Store) GetPosts(c *gin.Context) {
var posts []models.Post
if err := h.DB.Find(&posts).Error; err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
@@ -22,7 +22,7 @@ func (h *Handler) GetPosts(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"data": models.Post{}})
}
func (h *Handler) CreatePost(c *gin.Context) {
func (h *Store) CreatePost(c *gin.Context) {
var input CreatePostInput
if err := c.ShouldBindBodyWithJSON(&input); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
@@ -36,7 +36,7 @@ func (h *Handler) CreatePost(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"data": post})
}
func (h *Handler) UpdatePost(c *gin.Context) {
func (h *Store) UpdatePost(c *gin.Context) {
id := c.Param("id")
var post models.Post
if err := h.DB.First(&post, id).Error; err != nil {