加入版本显示

This commit is contained in:
2026-08-07 17:37:58 +08:00
parent 01aee47024
commit ea2d33d1bf
7 changed files with 61 additions and 1 deletions
+8
View File
@@ -84,6 +84,10 @@ func NewRouter(cfg configpkg.WebConfig, consoleLog bool, store *storepkg.Store,
return r
}
const BackendVersion = "1.0.0"
var CommitVersion = "dev"
func registerAPIRoutes(r gin.IRouter, store *storepkg.Store, mapTileCacheDir string) {
r.GET("/health", func(c *gin.Context) {
status := gin.H{"status": "ok", "database": "ok"}
@@ -96,6 +100,10 @@ func registerAPIRoutes(r gin.IRouter, store *storepkg.Store, mapTileCacheDir str
c.JSON(http.StatusOK, status)
})
r.GET("/version", func(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"version": BackendVersion, "commit": CommitVersion})
})
registerNodeInfoRoutes(r, store, "/nodeinfo")
registerNodeInfoRoutes(r, store, "/nodes")
registerMapReportRoutes(r, store)