75f3dd141c
CodeQL / Analyze (go) (push) Has been cancelled
CodeQL / Analyze (actions) (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
CI and Release / lint-frontend (push) Has been cancelled
CI and Release / dockerfile-scan (push) Has been cancelled
CI and Release / test-frontend (push) Has been cancelled
CI and Release / lint-verification-agent (push) Has been cancelled
CI and Release / test-verification-agent (push) Has been cancelled
CI and Release / e2e-verification-agent (push) Has been cancelled
CI and Release / test-backend (push) Has been cancelled
CI and Release / build-dev-image (push) Has been cancelled
CI and Release / push-dev-image (push) Has been cancelled
CI and Release / build-image (push) Has been cancelled
CI and Release / build-verification-image (push) Has been cancelled
CI and Release / determine-version (push) Has been cancelled
CI and Release / push-image (push) Has been cancelled
CI and Release / push-verification-image (12) (push) Has been cancelled
CI and Release / lint-backend (push) Has been cancelled
CI and Release / push-verification-image (17) (push) Has been cancelled
CI and Release / push-verification-image (18) (push) Has been cancelled
CI and Release / release (push) Has been cancelled
CI and Release / publish-helm-chart (push) Has been cancelled
CI and Release / push-verification-image (13) (push) Has been cancelled
CI and Release / push-verification-image (14) (push) Has been cancelled
CI and Release / push-verification-image (15) (push) Has been cancelled
CI and Release / push-verification-image (16) (push) Has been cancelled
39 lines
875 B
Go
39 lines
875 B
Go
package system_version
|
|
|
|
import (
|
|
"net/http"
|
|
"os"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
const defaultVersion = "3.26.0"
|
|
|
|
type VersionController struct{}
|
|
|
|
func (c *VersionController) RegisterRoutes(router *gin.RouterGroup) {
|
|
router.GET("/system/version", c.GetVersion)
|
|
}
|
|
|
|
// GetVersion
|
|
// @Summary Get application version
|
|
// @Description Returns the current application version
|
|
// @Tags system/version
|
|
// @Produce json
|
|
// @Success 200 {object} VersionResponse
|
|
// @Router /system/version [get]
|
|
func (c *VersionController) GetVersion(ctx *gin.Context) {
|
|
ctx.JSON(http.StatusOK, VersionResponse{Version: GetAppVersion()})
|
|
}
|
|
|
|
// GetAppVersion returns the current application version, falling back to a
|
|
// hardcoded default when APP_VERSION is unset.
|
|
func GetAppVersion() string {
|
|
version := os.Getenv("APP_VERSION")
|
|
if version == "" {
|
|
return defaultVersion
|
|
}
|
|
|
|
return version
|
|
}
|