Initial commit

This commit is contained in:
2023-03-26 16:11:00 +03:00
commit 92469fa3a2
47 changed files with 5610 additions and 0 deletions

38
application/config.go Normal file
View File

@@ -0,0 +1,38 @@
package application
import (
"context"
"fmt"
"github.com/sethvargo/go-envconfig"
)
const envPrefix = "WEBARCHIVE_"
func NewConfig(ctx context.Context) (Config, error) {
cfg := Config{}
lookuper := envconfig.MultiLookuper(
envconfig.PrefixLookuper(envPrefix, envconfig.OsLookuper()),
envconfig.OsLookuper(),
)
if err := envconfig.ProcessWith(ctx, &cfg, lookuper); err != nil {
return Config{}, fmt.Errorf("process env: %w", err)
}
return cfg, nil
}
type Config struct {
DB DB `env:",prefix=DB_"`
Logging Logging `env:",prefix=LOGGING_"`
}
type DB struct {
Path string `env:"PATH,default=./db"`
}
type Logging struct {
Debug bool `env:"DEBUG"`
}