adding spotify api interaction
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user