mirror of
https://github.com/EZ-Api/ez-api.git
synced 2026-01-13 09:37:53 +00:00
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
62 lines
1.7 KiB
Makefile
62 lines
1.7 KiB
Makefile
.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
|
|
|
|
# Generate swagger documentation using go run (no install needed)
|
|
swagger:
|
|
@echo "Generating Swagger documentation..."
|
|
go run github.com/swaggo/swag/cmd/swag@latest init -g cmd/server/main.go -o docs --parseDependency --parseInternal
|
|
|
|
# Build the binary
|
|
build: swagger
|
|
@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 -ldflags "$(LDFLAGS)" -o ez-api ./cmd/server
|
|
|
|
# Run tests
|
|
test:
|
|
go test -v ./...
|
|
|
|
# Clean build artifacts
|
|
clean:
|
|
rm -f ez-api
|
|
rm -rf docs/
|
|
|
|
# Run in development mode
|
|
dev: swagger
|
|
go run -ldflags "$(LDFLAGS)" ./cmd/server
|
|
|
|
# Format code
|
|
fmt:
|
|
go fmt ./...
|
|
|
|
# Lint code
|
|
lint:
|
|
@which golangci-lint > /dev/null || go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
|
|
golangci-lint run
|
|
|
|
# Generate swagger only (alias)
|
|
docs: swagger
|
|
|
|
# Help
|
|
help:
|
|
@echo "Available targets:"
|
|
@echo " all - Generate swagger docs and build (default)"
|
|
@echo " build - Generate swagger and build binary"
|
|
@echo " build-fast - Build binary without swagger regeneration"
|
|
@echo " swagger - Generate Swagger documentation"
|
|
@echo " docs - Alias for swagger"
|
|
@echo " test - Run tests"
|
|
@echo " dev - Run in development mode"
|
|
@echo " clean - Remove build artifacts"
|
|
@echo " fmt - Format code"
|
|
@echo " lint - Run linter"
|
|
@echo " help - Show this help"
|