refactor: move Go source files to src/ directory

Organize project structure by relocating all Go files to a src/ directory,
following standard Go project conventions and improving code organization.
This commit is contained in:
db123-test
2026-05-05 11:46:58 +03:30
parent f525eaa8f3
commit 33b0e4e30e
6 changed files with 0 additions and 0 deletions

41
src/config.go Normal file
View File

@@ -0,0 +1,41 @@
package main
import (
"os"
"time"
)
type Config struct {
Port string
APIToken string
DataDir string
CleanupInterval time.Duration
DBPath string
}
func loadConfig() Config {
return Config{
Port: getEnv("AUTH_PROXY_PORT", "8080"),
APIToken: getEnv("AUTH_PROXY_API_TOKEN", ""),
DataDir: getEnv("DATA_DIR", "/data"),
CleanupInterval: parseDuration("CLEANUP_INTERVAL", 60*time.Second),
DBPath: getEnv("AUTH_PROXY_DB_PATH", "/data/auth-proxy.db"),
}
}
func getEnv(key, defaultValue string) string {
if v := os.Getenv(key); v != "" {
return v
}
return defaultValue
}
func parseDuration(key string, defaultVal time.Duration) time.Duration {
if v := os.Getenv(key); v != "" {
d, err := time.ParseDuration(v)
if err == nil {
return d
}
}
return defaultVal
}