All checks were successful
Build / build (push) Successful in 2m35s
#2 - Added request to download the newest version of the app #3 - Added request to check progress during sync #4 - Now blocking all request while sync is in progress #5 - Implemented ants for thread pooling #6 - Changed the sync request to now only start the sync
42 lines
1.1 KiB
Go
42 lines
1.1 KiB
Go
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)
|
|
}
|