mirror of
https://github.com/EZ-Api/ez-api.git
synced 2026-01-13 17:47:51 +00:00
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:
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user