feat: show version in admin page

This commit is contained in:
Felipe M 2025-04-21 18:08:40 +02:00
parent c920eb94a0
commit a0f12efd65
Signed by: fmartingr
GPG key ID: CCFBC5637D4000A8
3 changed files with 41 additions and 14 deletions

View file

@ -9,6 +9,7 @@ import (
"net/http"
"os"
"os/signal"
"runtime/debug"
"strings"
"syscall"
"time"
@ -26,12 +27,13 @@ import (
// App represents the application
type App struct {
config *config.Config
logger *slog.Logger
db *db.Database
router *http.ServeMux
queue *queue.Queue
admin *admin.Admin
config *config.Config
logger *slog.Logger
db *db.Database
router *http.ServeMux
queue *queue.Queue
admin *admin.Admin
version string
}
// New creates a new App instance
@ -48,16 +50,24 @@ func New(cfg *config.Config, logger *slog.Logger) (*App, error) {
// Initialize message queue
messageQueue := queue.New(logger)
// Get version information
version := ""
info, ok := debug.ReadBuildInfo()
if ok {
version = info.Main.Version
}
// Initialize admin interface
adminInterface := admin.New(cfg, database)
adminInterface := admin.New(cfg, database, version)
return &App{
config: cfg,
logger: logger,
db: database,
router: router,
queue: messageQueue,
admin: adminInterface,
config: cfg,
logger: logger,
db: database,
router: router,
queue: messageQueue,
admin: adminInterface,
version: version,
}, nil
}