package server import ( "github.com/labstack/echo/v4" "log" "music-server/internal/backend" "net/http" ) type DownloadHandler struct { } func NewDownloadHandler() *DownloadHandler { return &DownloadHandler{} } func (d *DownloadHandler) checkLatest(ctx echo.Context) error { log.Println("Checking latest version") latest := backend.CheckLatest() return ctx.JSON(http.StatusOK, latest) } func (d *DownloadHandler) listAssetsOfLatest(ctx echo.Context) error { log.Println("Listing assets") assets := backend.ListAssetsOfLatest() return ctx.JSON(http.StatusOK, assets) } func (d *DownloadHandler) downloadLatestWindows(ctx echo.Context) error { log.Println("Downloading latest windows") asset := backend.DownloadLatestWindows() ctx.Response().Header().Set("Content-Type", "application/octet-stream") return ctx.Redirect(http.StatusFound, asset) } func (d *DownloadHandler) downloadLatestLinux(ctx echo.Context) error { log.Println("Downloading latest linux") asset := backend.DownloadLatestLinux() ctx.Response().Header().Set("Content-Type", "application/octet-stream") return ctx.Redirect(http.StatusFound, asset) }