173e23f531
- Added ExternalAPIURL to EqualizeConfig for public EQ interface usage. - Updated loadEqualize function to initialize ExternalAPIURL from environment variable or default value. - Refactored reqEqualize method to accept apiURL as a parameter for improved flexibility. - Introduced eqAPIURL method to determine the appropriate API URL based on the source.
34 lines
813 B
Go
34 lines
813 B
Go
package config
|
|
|
|
import "os"
|
|
|
|
const defaultExternalEQAPIURL = "https://autoeq.app/equalize"
|
|
|
|
type EqualizeConfig struct {
|
|
APIURL string // 内网 EQ 接口(正式环境 Eafonyoung 源使用)
|
|
ExternalAPIURL string // 公网 EQ 接口(正式环境非 Eafonyoung 源使用)
|
|
}
|
|
|
|
func loadEqualize(env string) EqualizeConfig {
|
|
external := getEnv("EQ_EXTERNAL_API_URL", defaultExternalEQAPIURL)
|
|
if os.Getenv("EQ_API_URL") != "" {
|
|
return EqualizeConfig{
|
|
APIURL: os.Getenv("EQ_API_URL"),
|
|
ExternalAPIURL: external,
|
|
}
|
|
}
|
|
|
|
switch env {
|
|
case "production":
|
|
return EqualizeConfig{
|
|
APIURL: "http://172.31.18.70:8000/equalize",
|
|
ExternalAPIURL: external,
|
|
}
|
|
default:
|
|
return EqualizeConfig{
|
|
APIURL: defaultExternalEQAPIURL,
|
|
ExternalAPIURL: external,
|
|
}
|
|
}
|
|
}
|