添加文件: server_tb_LinkedMall/internal/config/config.go
This commit is contained in:
parent
ab7905ede2
commit
80fab4c4bb
|
|
@ -0,0 +1,38 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
"os"
|
||||
)
|
||||
|
||||
// Config 应用配置
|
||||
type Config struct {
|
||||
ServerPort string
|
||||
AccessKeyId string
|
||||
AccessKeySecret string
|
||||
RegionId string
|
||||
Endpoint string
|
||||
BasePath string
|
||||
DefaultPurchaserId string
|
||||
CallbackURL string
|
||||
}
|
||||
|
||||
// LoadConfig 从环境变量加载配置
|
||||
func LoadConfig() *Config {
|
||||
return &Config{
|
||||
ServerPort: getEnv("SERVER_PORT", "8080"),
|
||||
AccessKeyId: getEnv("LINKEDMALL_AK", ""),
|
||||
AccessKeySecret: getEnv("LINKEDMALL_SK", ""),
|
||||
RegionId: getEnv("LINKEDMALL_REGION_ID", "cn-zhangjiakou"),
|
||||
Endpoint: getEnv("LINKEDMALL_ENDPOINT", "linkedmall.cn-zhangjiakou.aliyuncs.com"),
|
||||
BasePath: getEnv("LINKEDMALL_BASE_PATH", "/opensaas-s2b/opensaas-s2b-biz-trade/v2"),
|
||||
DefaultPurchaserId: getEnv("LINKEDMALL_PURCHASER_ID", ""),
|
||||
CallbackURL: getEnv("LINKEDMALL_CALLBACK_URL", ""),
|
||||
}
|
||||
}
|
||||
|
||||
func getEnv(key, fallback string) string {
|
||||
if v := os.Getenv(key); v != "" {
|
||||
return v
|
||||
}
|
||||
return fallback
|
||||
}
|
||||
Loading…
Reference in New Issue