Files
2026-05-27 08:18:36 +08:00

37 lines
955 B
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 配置读取:环境变量、默认上游地址、布尔开关解析。
package forward
import (
"os"
"strings"
)
// 政务云默认上游地址(未配置 SUPERVISE_TARGET_URL / FILE_TARGET_URL 时使用)。
const (
DefaultSuperviseTarget = "https://59.202.52.129:28212/province/supervise/data"
DefaultFileTarget = "https://59.202.52.129:28211/mng/file/auth/upload"
)
// env 读取字符串环境变量;空或仅空白时返回默认值 def。
func env(key, def string) string {
if v := strings.TrimSpace(os.Getenv(key)); v != "" {
return v
}
return def
}
// envBool 读取布尔环境变量。
// 未设置或空 → 返回 deffalse/0/no/off不区分大小写→ false其余非空值 → true。
func envBool(key string, def bool) bool {
v := strings.TrimSpace(os.Getenv(key))
if v == "" {
return def
}
switch strings.ToLower(v) {
case "false", "0", "no", "off":
return false
default:
return true
}
}