44 lines
1.3 KiB
Go
44 lines
1.3 KiB
Go
// 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/>.
|
|
|
|
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
|
|
}
|