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

@@ -247,17 +247,6 @@ definitions:
updatedAt:
type: string
type: object
github_com_ez-api_ez-api_internal_service.HealthStatus:
properties:
database:
type: string
redis:
type: string
status:
type: string
uptime:
type: string
type: object
github_com_ez-api_ez-api_internal_service.LogWebhookConfig:
properties:
cooldown_seconds:
@@ -328,6 +317,21 @@ definitions:
description: Valid is true if Time is not NULL
type: boolean
type: object
internal_api.AboutResponse:
properties:
description:
example: High-performance LLM API gateway
type: string
name:
example: EZ-API Gateway
type: string
repository:
example: https://github.com/ez-api/ez-api
type: string
version:
example: 0.1.0
type: string
type: object
internal_api.AccessResponse:
properties:
default_namespace:
@@ -712,6 +716,18 @@ definitions:
tokens:
type: integer
type: object
internal_api.StatusResponse:
properties:
status:
example: ok
type: string
uptime:
example: 72h30m15s
type: string
version:
example: 0.1.0
type: string
type: object
internal_api.TokenView:
properties:
allow_ips:
@@ -943,6 +959,19 @@ info:
title: EZ-API Control Plane
version: 0.0.1
paths:
/about:
get:
description: Returns system metadata for display on an about page
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/internal_api.AboutResponse'
summary: Get system information
tags:
- Public
/admin/api-keys:
get:
description: List API keys
@@ -2744,23 +2773,6 @@ paths:
summary: Force sync snapshot
tags:
- admin
/api/status/test:
get:
description: Checks Redis/PostgreSQL connections and reports status
produces:
- application/json
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'
summary: Test dependency connectivity
tags:
- system
/auth/whoami:
get:
description: |-
@@ -2845,6 +2857,19 @@ paths:
summary: Ingest logs
tags:
- system
/status:
get:
description: Returns public runtime status information without sensitive data
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/internal_api.StatusResponse'
summary: Get system status
tags:
- Public
/v1/logs:
get:
description: List request logs for the authenticated master