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

@@ -24,6 +24,26 @@ const docTemplate = `{
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
"paths": {
"/about": {
"get": {
"description": "Returns system metadata for display on an about page",
"produces": [
"application/json"
],
"tags": [
"Public"
],
"summary": "Get system information",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/internal_api.AboutResponse"
}
}
}
}
},
"/admin/api-keys": {
"get": {
"security": [
@@ -2844,32 +2864,6 @@ const docTemplate = `{
}
}
},
"/api/status/test": {
"get": {
"description": "Checks Redis/PostgreSQL connections and reports status",
"produces": [
"application/json"
],
"tags": [
"system"
],
"summary": "Test dependency connectivity",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/github_com_ez-api_ez-api_internal_service.HealthStatus"
}
},
"503": {
"description": "Service Unavailable",
"schema": {
"$ref": "#/definitions/github_com_ez-api_ez-api_internal_service.HealthStatus"
}
}
}
}
},
"/auth/whoami": {
"get": {
"security": [
@@ -2990,6 +2984,26 @@ const docTemplate = `{
}
}
},
"/status": {
"get": {
"description": "Returns public runtime status information without sensitive data",
"produces": [
"application/json"
],
"tags": [
"Public"
],
"summary": "Get system status",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/internal_api.StatusResponse"
}
}
}
}
},
"/v1/logs": {
"get": {
"security": [
@@ -3925,23 +3939,6 @@ const docTemplate = `{
}
}
},
"github_com_ez-api_ez-api_internal_service.HealthStatus": {
"type": "object",
"properties": {
"database": {
"type": "string"
},
"redis": {
"type": "string"
},
"status": {
"type": "string"
},
"uptime": {
"type": "string"
}
}
},
"github_com_ez-api_ez-api_internal_service.LogWebhookConfig": {
"type": "object",
"properties": {
@@ -4049,6 +4046,27 @@ const docTemplate = `{
}
}
},
"internal_api.AboutResponse": {
"type": "object",
"properties": {
"description": {
"type": "string",
"example": "High-performance LLM API gateway"
},
"name": {
"type": "string",
"example": "EZ-API Gateway"
},
"repository": {
"type": "string",
"example": "https://github.com/ez-api/ez-api"
},
"version": {
"type": "string",
"example": "0.1.0"
}
}
},
"internal_api.AccessResponse": {
"type": "object",
"properties": {
@@ -4635,6 +4653,23 @@ const docTemplate = `{
}
}
},
"internal_api.StatusResponse": {
"type": "object",
"properties": {
"status": {
"type": "string",
"example": "ok"
},
"uptime": {
"type": "string",
"example": "72h30m15s"
},
"version": {
"type": "string",
"example": "0.1.0"
}
}
},
"internal_api.TokenView": {
"type": "object",
"properties": {