mirror of
https://github.com/EZ-Api/ez-api.git
synced 2026-01-13 17:47:51 +00:00
feat(api): add public status endpoints with version injection
Replace health_handler with status_handler providing public /status and /about endpoints. Add build-time version injection via ldflags in Makefile, and support --version/-v CLI flag. - Add /status endpoint returning runtime status, uptime, and version - Add /about endpoint with system metadata (name, description, repo) - Configure VERSION variable with git describe fallback - Update swagger docs and api.md for new public endpoints - Remove deprecated /api/status/test endpoint
This commit is contained in:
@@ -77,6 +77,12 @@ func isOriginAllowed(allowed []string, origin string) bool {
|
||||
}
|
||||
|
||||
func main() {
|
||||
// Handle --version flag before any initialization
|
||||
if len(os.Args) > 1 && (os.Args[1] == "--version" || os.Args[1] == "-v") {
|
||||
fmt.Printf("ez-api %s\n", api.Version)
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
logger, _ := logging.New(logging.Options{Service: "ez-api"})
|
||||
if len(os.Args) > 1 && os.Args[1] == "import" {
|
||||
code := runImport(logger, os.Args[2:])
|
||||
@@ -196,7 +202,7 @@ func main() {
|
||||
masterService := service.NewMasterService(db)
|
||||
statsService := service.NewStatsService(rdb)
|
||||
healthService := service.NewHealthCheckService(db, rdb)
|
||||
healthHandler := api.NewHealthHandler(healthService)
|
||||
statusHandler := api.NewStatusHandler(healthService)
|
||||
|
||||
handler := api.NewHandler(db, logDB, syncService, logWriter, rdb, logPartitioner)
|
||||
adminHandler := api.NewAdminHandler(db, logDB, masterService, syncService, statsService, logPartitioner)
|
||||
@@ -265,7 +271,10 @@ func main() {
|
||||
}
|
||||
c.JSON(httpStatus, status)
|
||||
})
|
||||
r.GET("/api/status/test", healthHandler.TestDeps)
|
||||
|
||||
// Public Status Endpoints
|
||||
r.GET("/status", statusHandler.Status)
|
||||
r.GET("/about", statusHandler.About)
|
||||
|
||||
// Swagger Documentation
|
||||
r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
|
||||
|
||||
Reference in New Issue
Block a user