package server import ( "net/http" "github.com/labstack/echo/v5" "music-server/internal/backend" ) type VersionHandler struct { } func NewVersionHandler() *VersionHandler { return &VersionHandler{} } // GetVersionHistory godoc // // @Summary Getting the version history of the backend // @Description get version history // @Tags version // @Accept json // @Produce json // @Success 200 {array} backend.VersionData // @Failure 404 {object} string // @Router /version/history [get] func (v *VersionHandler) GetVersionHistory(ctx *echo.Context) error { versionHistory := backend.GetVersionHistory() if len(versionHistory) == 0 { return ctx.JSON(http.StatusNotFound, "version not found") } return ctx.JSON(http.StatusOK, versionHistory) } // GetLatestVersion godoc // // @Summary Getting the latest version of the backend // @Description get latest version info // @Tags version // @Accept json // @Produce json // @Success 200 {object} backend.VersionData // @Failure 404 {object} string // @Router /version [get] func (v *VersionHandler) GetLatestVersion(ctx *echo.Context) error { latestVersion := backend.GetLatestVersion() if latestVersion.Version == "" { return ctx.JSON(http.StatusNotFound, "version not found") } return ctx.JSON(http.StatusOK, latestVersion) }