s3staticsite/config.go

45 lines
1.3 KiB
Go
Raw Permalink Normal View History

2024-04-01 05:51:10 +00:00
// s3staticsites: servers http requests from an S3 bucket
// Copyright (C) 2024 Finn Herzfeld
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
2024-02-18 22:30:11 +00:00
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
}