patch(version): Implemented version reporting for the app
Some checks failed
Build and Publish Docker Image / deploy (push) Has been cancelled

This commit is contained in:
2026-05-04 00:40:02 +03:00
parent bcdcce8fbd
commit 0bdf11d3a7
3 changed files with 22 additions and 0 deletions

View File

@@ -24,6 +24,7 @@ func (app *App) handleIndex(ctx *gin.Context) {
"UploadsEnabled": app.config.GuestUploadsEnabled && app.config.APIEnabled,
"MaxFileSizeBytes": app.config.GlobalMaxFileSizeBytes,
"MaxBoxSizeBytes": app.config.GlobalMaxBoxSizeBytes,
"AppVersion": app.appVersion,
})
}

View File

@@ -3,7 +3,9 @@ package server
import (
"encoding/json"
"html/template"
"os"
"path/filepath"
"strings"
"time"
"github.com/gin-contrib/gzip"
@@ -23,6 +25,7 @@ type App struct {
activityStore *activity.Store
alertStore *alerts.Store
securityGuard *security.Guard
appVersion string
}
func Run(addr string) error {
@@ -56,12 +59,14 @@ func Run(addr string) error {
activityStore: activity.NewStore(filepath.Join(cfg.DBDir, "activity_log.json")),
alertStore: alerts.NewStore(filepath.Join(cfg.DBDir, "alerts.json")),
securityGuard: security.NewGuard(),
appVersion: currentAppVersion(),
}
if err := app.reloadSecurityConfig(); err != nil {
return err
}
router := gin.Default()
router.Use(app.versionHeaderMiddleware())
router.Use(app.securityMiddleware())
router.NoRoute(app.handleNoRoute)
htmlTemplates, err := loadHTMLTemplates()
@@ -149,3 +154,18 @@ func (app *App) handleHealth(c *gin.Context) {
"status": "healthy",
})
}
func (app *App) versionHeaderMiddleware() gin.HandlerFunc {
return func(ctx *gin.Context) {
ctx.Header("X-App-Version", app.appVersion)
ctx.Next()
}
}
func currentAppVersion() string {
version := strings.TrimSpace(os.Getenv("APP_VERSION"))
if version == "" {
return "dev"
}
return version
}

View File

@@ -126,6 +126,7 @@
<div class="win98-statusbar upload-statusbar">
<span id="status-text">{{ if .UploadsEnabled }}Ready · drag files anywhere onto the window{{ else }}Guest uploads are disabled{{ end }}</span>
<span>WarpBox</span>
<span>v{{ .AppVersion }}</span>
</div>
</section>