feat(swagger): support dynamic host via EZ_SWAGGER_HOST env var

- Add ServerConfig.SwaggerHost field
- Set docs.SwaggerInfo.Host dynamically at startup
- Update docker-compose, k8s manifests, and .env.example
This commit is contained in:
2025-12-25 10:52:49 +08:00
parent 6a16712b9d
commit 41998a3584
7 changed files with 27 additions and 3 deletions

View File

@@ -14,7 +14,7 @@ import (
"syscall"
"time"
_ "github.com/ez-api/ez-api/docs"
"github.com/ez-api/ez-api/docs"
"github.com/ez-api/ez-api/internal/api"
"github.com/ez-api/ez-api/internal/config"
"github.com/ez-api/ez-api/internal/cron"
@@ -246,6 +246,13 @@ func main() {
c.Next()
})
// 动态设置 Swagger Host
if cfg.Server.SwaggerHost != "" {
docs.SwaggerInfo.Host = cfg.Server.SwaggerHost
} else {
docs.SwaggerInfo.Host = "" // 使用相对路径
}
// Health Check Endpoint
r.GET("/health", func(c *gin.Context) {
status := healthService.Check(c.Request.Context())