30 lines
459 B
Go
30 lines
459 B
Go
package middleware
|
|
|
|
import (
|
|
"log"
|
|
"os"
|
|
"strings"
|
|
)
|
|
|
|
func envBool(key string, fallback bool) bool {
|
|
raw := strings.TrimSpace(strings.ToLower(os.Getenv(key)))
|
|
if raw == "" {
|
|
return fallback
|
|
}
|
|
switch raw {
|
|
case "1", "true", "yes", "on":
|
|
return true
|
|
case "0", "false", "no", "off":
|
|
return false
|
|
default:
|
|
return fallback
|
|
}
|
|
}
|
|
|
|
func policyLogf(enabled bool, format string, args ...any) {
|
|
if !enabled {
|
|
return
|
|
}
|
|
log.Printf(format, args...)
|
|
}
|