mirror of
https://github.com/IS1DI/x0gp.git
synced 2026-07-16 20:47:55 +00:00
Add gh workflow for release, new fields in podium and versioning
This commit is contained in:
@@ -62,7 +62,7 @@ import (
|
||||
"github.com/x0gp/server/internal/transport"
|
||||
)
|
||||
|
||||
const serverVersion = "0.1.0-poc"
|
||||
var serverVersion = "0.1.0-poc"
|
||||
|
||||
var (
|
||||
upgrader = websocket.Upgrader{
|
||||
@@ -95,9 +95,15 @@ func main() {
|
||||
devMode = flag.Bool("dev", true, "enable development mode")
|
||||
seedRaces = flag.Bool("seed-races", false, "seed mock race data (finished/live/plans) on startup")
|
||||
seedReset = flag.Bool("reset", false, "with --seed-races, wipe seed-managed data before inserting")
|
||||
version = flag.Bool("version", false, "print version and exit")
|
||||
)
|
||||
flag.Parse()
|
||||
|
||||
if *version {
|
||||
fmt.Println(serverVersion)
|
||||
return
|
||||
}
|
||||
|
||||
if *addr != "" {
|
||||
_ = os.Setenv("X0GP_HTTP_ADDR", *addr)
|
||||
}
|
||||
@@ -118,7 +124,7 @@ func main() {
|
||||
}
|
||||
|
||||
logger := newLogger(cfg.LogLevel)
|
||||
logger.Info("starting x0gp poc-server",
|
||||
logger.Info(fmt.Sprintf("starting x0gp poc-server version %s", serverVersion),
|
||||
"version", serverVersion,
|
||||
"addr", cfg.HTTPAddr,
|
||||
"tick_hz", cfg.TickRate,
|
||||
@@ -276,6 +282,7 @@ func main() {
|
||||
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc("/health", healthHandler(hub, engine))
|
||||
mux.HandleFunc("/api/version", versionHandler())
|
||||
mux.HandleFunc("/stats", statsHandler(hub, engine))
|
||||
mux.HandleFunc("/api/catalog", catalogHandler(cat))
|
||||
mux.HandleFunc("/api/tracks", tracksRouter(cat))
|
||||
@@ -366,6 +373,23 @@ func (h *Hub) BroadcastSnapshot(snap transport.RaceSnapshot) {
|
||||
|
||||
// HTTP handlers ------------------------------------------------------------
|
||||
|
||||
// versionHandler godoc
|
||||
// @Summary Get server version
|
||||
// @Description Returns the current server version.
|
||||
// @Tags system
|
||||
// @Produce json
|
||||
// @Success 200 {object} transport.VersionResponse "Success"
|
||||
// @Router /api/version [get]
|
||||
func versionHandler() http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, _ *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
_ = json.NewEncoder(w).Encode(transport.VersionResponse{
|
||||
Version: serverVersion,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// healthHandler godoc
|
||||
// @Summary Liveness probe
|
||||
// @Description Returns 200 OK with current engine phase, WS connection count and total snapshot drops. Intended for load-balancer health checks.
|
||||
|
||||
@@ -485,6 +485,9 @@ func lobbyToWireFinished(m lobby.RaceMeta, podium []races.PodiumEntry) transport
|
||||
DriverID: p.DriverID,
|
||||
Name: p.Name,
|
||||
TotalTimeMs: p.TotalTimeMs,
|
||||
Nickname: p.Nickname,
|
||||
AvatarUrl: p.AvatarUrl,
|
||||
ClanID: p.ClanID,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user