feat: openapi supoort

This commit is contained in:
engigu
2026-03-05 22:22:46 +08:00
parent 9fec4ecdb5
commit 863a298609
22 changed files with 1266 additions and 227 deletions
-21
View File
@@ -31,17 +31,10 @@ type SecurityConfig struct {
Secret string `ini:"secret"`
}
type SwaggerConfig struct {
Enabled bool `ini:"enabled"`
User string `ini:"user"`
Password string `ini:"password"`
}
type AppConfig struct {
Server ServerConfig `ini:"server"`
Database DatabaseConfig `ini:"database"`
Security SecurityConfig `ini:"security"`
Swagger SwaggerConfig `ini:"swagger"`
}
var Config *AppConfig
@@ -82,11 +75,6 @@ func LoadConfig(path string) (*AppConfig, error) {
Security: SecurityConfig{
Secret: "",
},
Swagger: SwaggerConfig{
Enabled: false,
User: "admin",
Password: "swagger_password",
},
}
// 检查配置文件是否存在
@@ -154,15 +142,6 @@ func applyEnvOverrides() {
// Security
getEnvStr("BH_SECRET", &Config.Security.Secret)
// Swagger
vSwaggerEnabled := os.Getenv("BH_SWAGGER_ENABLED")
if vSwaggerEnabled == "true" || vSwaggerEnabled == "1" {
Config.Swagger.Enabled = true
} else if vSwaggerEnabled == "false" || vSwaggerEnabled == "0" {
Config.Swagger.Enabled = false
}
getEnvStr("BH_SWAGGER_USER", &Config.Swagger.User)
getEnvStr("BH_SWAGGER_PASSWORD", &Config.Swagger.Password)
}
func GetConfig() *AppConfig {