This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"music-server/internal/backend"
|
||||
"net/http"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
@@ -155,21 +156,17 @@ func (m *MusicHandler) GetAllGamesRandom(ctx echo.Context) error {
|
||||
return ctx.JSON(http.StatusOK, gameList)
|
||||
}
|
||||
|
||||
type played struct {
|
||||
Song int
|
||||
}
|
||||
|
||||
func (m *MusicHandler) PutPlayed(ctx echo.Context) error {
|
||||
if backend.Syncing {
|
||||
log.Println("Syncing is in progress")
|
||||
return ctx.JSON(http.StatusLocked, "Syncing is in progress")
|
||||
}
|
||||
var played played
|
||||
err := ctx.Bind(&played)
|
||||
song, err := strconv.Atoi(ctx.QueryParam("song"))
|
||||
if err != nil {
|
||||
return ctx.JSON(http.StatusBadRequest, err)
|
||||
}
|
||||
backend.SetPlayed(played.Song)
|
||||
log.Println("song", song)
|
||||
backend.SetPlayed(song)
|
||||
return ctx.NoContent(http.StatusOK)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user