Read every setting through viper (closes #211)
check / check (push) Successful in 3m47s

servewaf's and rproxy's settings are read through viper, bound to the same environment variable names as before, in place of the os.LookupEnv function Main passed down. NewViper turns AutomaticEnv and AllowEmptyEnv on, so a setting that is set but empty reads as set, as it did. The _FILE forms, their errors, and rproxy reading no file form are unchanged, and the settings tests pass set into a viper instead of a lookup function.

Model: deepseek-v4-pro
This commit is contained in:
2026-11-07 03:03:47 +00:00
parent f8676debda
commit 9c755ee358
16 changed files with 223 additions and 143 deletions
+7 -4
View File
@@ -9,6 +9,8 @@ import (
"testing"
"time"
"github.com/spf13/viper"
"sneak.berlin/go/smallwebwaf/internal/config"
)
@@ -32,11 +34,12 @@ const (
// rproxyConfig reads rproxy's settings from env.
func rproxyConfig(env map[string]string) (*config.RProxy, error) {
return config.RProxyFromEnvironment(func(name string) (string, bool) {
value, ok := env[name]
v := viper.New()
for name, value := range env {
v.Set(name, value)
}
return value, ok
})
return config.RProxyFromEnvironment(v)
}
func TestRProxyDefaults(t *testing.T) {