29 lines
877 B
Go
29 lines
877 B
Go
package common
|
|
|
|
import "os"
|
|
|
|
type Config struct {
|
|
RustFSEndpoint string
|
|
RustFSAccessKeyID string
|
|
RustFSSecretAccessKey string
|
|
RustFSRegion string
|
|
ServerPort string
|
|
}
|
|
|
|
func LoadConfig() *Config {
|
|
return &Config{
|
|
RustFSEndpoint: getEnv("RUSTFS_ENDPOINT_URL", "http://192.168.1.22:20060"), // Default to docker-compose port
|
|
RustFSAccessKeyID: getEnv("RUSTFS_ACCESS_KEY_ID", "xiangning"), // Default from user input
|
|
RustFSSecretAccessKey: getEnv("RUSTFS_SECRET_ACCESS_KEY", "xn001624."), // Default from user input
|
|
RustFSRegion: getEnv("RUSTFS_REGION", "us-east-1"), // Default region
|
|
ServerPort: getEnv("SERVER_PORT", "8080"),
|
|
}
|
|
}
|
|
|
|
func getEnv(key, fallback string) string {
|
|
if value, ok := os.LookupEnv(key); ok {
|
|
return value
|
|
}
|
|
return fallback
|
|
}
|