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:
zenfun
2025-12-27 13:24:13 +08:00
parent 3d39c591fd
commit 637bfa8210
8 changed files with 317 additions and 159 deletions

View File

@@ -1,5 +1,9 @@
.PHONY: all build swagger test clean dev
# Version injection - can be overridden via make build VERSION=v1.0.0
VERSION ?= $(shell git describe --tags --always 2>/dev/null || echo "v0.1.0-dev")
LDFLAGS := -X github.com/ez-api/ez-api/internal/api.Version=$(VERSION)
# Default target
all: swagger build
@@ -10,12 +14,12 @@ swagger:
# Build the binary
build: swagger
@echo "Building ez-api..."
go build -o ez-api ./cmd/server
@echo "Building ez-api $(VERSION)..."
go build -ldflags "$(LDFLAGS)" -o ez-api ./cmd/server
# Build without swagger regeneration (for quick iteration)
build-fast:
go build -o ez-api ./cmd/server
go build -ldflags "$(LDFLAGS)" -o ez-api ./cmd/server
# Run tests
test:
@@ -28,7 +32,7 @@ clean:
# Run in development mode
dev: swagger
go run ./cmd/server
go run -ldflags "$(LDFLAGS)" ./cmd/server
# Format code
fmt: