adding spotify api interaction
This commit is contained in:
@@ -13,7 +13,7 @@ type CreatePostInput struct {
|
|||||||
Author string `json:"author" binding:"required"`
|
Author string `json:"author" binding:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Handler) GetPosts(c *gin.Context) {
|
func (h *Store) GetPosts(c *gin.Context) {
|
||||||
var posts []models.Post
|
var posts []models.Post
|
||||||
if err := h.DB.Find(&posts).Error; err != nil {
|
if err := h.DB.Find(&posts).Error; err != nil {
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
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{}})
|
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
|
var input CreatePostInput
|
||||||
if err := c.ShouldBindBodyWithJSON(&input); err != nil {
|
if err := c.ShouldBindBodyWithJSON(&input); err != nil {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
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})
|
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")
|
id := c.Param("id")
|
||||||
var post models.Post
|
var post models.Post
|
||||||
if err := h.DB.First(&post, id).Error; err != nil {
|
if err := h.DB.First(&post, id).Error; err != nil {
|
||||||
|
|||||||
21
backend/handlers/handle_spotify.go
Normal file
21
backend/handlers/handle_spotify.go
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
package handlers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (store *Store) ListeningTo(c *gin.Context) {
|
||||||
|
|
||||||
|
// Communicate with spotify API
|
||||||
|
// Return if I'm listening to a song
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (store *Store) SendSong(c *gin.Context) {
|
||||||
|
|
||||||
|
// Communicate with spotify API
|
||||||
|
// Play song on spotify
|
||||||
|
// Disallow new song for duration of song
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
@@ -4,6 +4,6 @@ import (
|
|||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Handler struct {
|
type Store struct {
|
||||||
DB *gorm.DB
|
DB *gorm.DB
|
||||||
}
|
}
|
||||||
1
backend/services/spotify.go
Normal file
1
backend/services/spotify.go
Normal file
@@ -0,0 +1 @@
|
|||||||
|
package services
|
||||||
Reference in New Issue
Block a user