refactor: unify config and data structures

This commit is contained in:
2026-08-30 19:54:34 +02:00
parent d3780e9e32
commit dd77a61b18
7 changed files with 148 additions and 288 deletions
+3 -13
View File
@@ -2,7 +2,6 @@ package main
import (
"context"
"flag"
"fmt"
"log/slog"
"net"
@@ -25,12 +24,8 @@ import (
)
func main() {
var cfgPath string
flag.StringVar(&cfgPath, "config", "config.yaml", "path to configuration file")
flag.Parse()
// ---- Configuration ----
cfg, err := config.Load(cfgPath)
cfg, err := config.Load()
if err != nil {
fmt.Fprintf(os.Stderr, "error loading config: %v\n", err)
os.Exit(1)
@@ -41,8 +36,7 @@ func main() {
logger.Info("starting DAV server",
"host", cfg.Server.Host,
"port", cfg.Server.Port,
"base_url", cfg.Server.BaseURL,
"tls", cfg.TLS.Enabled)
"base_url", cfg.Server.BaseURL)
// ---- Storage ----
st, err := store.NewStore(cfg.Storage.DataDir)
@@ -143,11 +137,7 @@ func main() {
}()
logger.Info("server ready", "addr", addr)
if cfg.TLS.Enabled {
err = srv.ListenAndServeTLS(cfg.TLS.CertFile, cfg.TLS.KeyFile)
} else {
err = srv.ListenAndServe()
}
err = srv.ListenAndServe()
if err != nil && err != http.ErrServerClosed {
logger.Error("server error", "error", err)
os.Exit(1)