s3staticsite/config.go
2024-02-18 14:30:11 -08:00

28 lines
605 B
Go

package main
import (
"os"
)
type Config struct {
Bind string `json:"bind"`
S3Endpoint string `json:"s3_endpoint"`
AccessKeyID string `json:"access_key_id"`
SecretAccessKey string `json:"secret_access_key"`
}
var config = Config{
Bind: getEnvWithDefault("BIND", ":5000"),
S3Endpoint: os.Getenv("S3_ENDPOINT"),
AccessKeyID: os.Getenv("ACCESS_KEY_ID"),
SecretAccessKey: os.Getenv("SECRET_ACCESS_KEY"),
}
func getEnvWithDefault(env string, defaultValue string) string {
value := os.Getenv(env)
if value == "" {
return defaultValue
}
return value
}