Replaced the gin framwwork with echo

This commit is contained in:
2025-01-13 11:57:48 +01:00
parent 8e2d22b899
commit 034ba35fbb
32 changed files with 348 additions and 266 deletions

View File

@@ -1,10 +1,11 @@
package api
import (
"log"
"music-server/pkg/server"
"net/http"
"github.com/gin-gonic/gin"
"github.com/labstack/echo"
)
type Sync struct {
@@ -14,25 +15,33 @@ func NewSync() *Sync {
return &Sync{}
}
func (s *Sync) SyncGames(ctx *gin.Context) {
func (s *Sync) SyncGames(ctx echo.Context) error {
server.SyncGames()
server.Reset()
ctx.JSON(http.StatusOK, "Games are synced")
return ctx.JSON(http.StatusOK, "Games are synced")
}
func (s *Sync) SyncGamesQuick(ctx *gin.Context) {
func (s *Sync) SyncGamesQuick(ctx echo.Context) error {
server.SyncGamesQuick()
server.Reset()
ctx.JSON(http.StatusOK, "Games are synced")
return ctx.JSON(http.StatusOK, "Games are synced")
}
func (s *Sync) SyncGamesNew(ctx *gin.Context) {
response := server.SyncGamesNew()
func (s *Sync) SyncGamesNewOnlyChanges(ctx echo.Context) error {
log.Println("Syncing games new")
response := server.SyncGamesNewOnlyChanges()
server.Reset()
ctx.JSON(http.StatusOK, response)
return ctx.JSON(http.StatusOK, response)
}
func (s *Sync) ResetGames(ctx *gin.Context) {
server.ResetDB()
ctx.JSON(http.StatusOK, "Games and songs are deleted from the database")
func (s *Sync) SyncGamesNewFull(ctx echo.Context) error {
log.Println("Syncing games new full")
response := server.SyncGamesNewFull()
server.Reset()
return ctx.JSON(http.StatusOK, response)
}
func (s *Sync) ResetGames(ctx echo.Context) error {
server.ResetDB()
return ctx.JSON(http.StatusOK, "Games and songs are deleted from the database")
}