#1 - Created request to check newest version of the app
All checks were successful
Build / build (push) Successful in 2m35s
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
This commit is contained in:
41
internal/server/downloadHandler.go
Normal file
41
internal/server/downloadHandler.go
Normal file
@@ -0,0 +1,41 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user