mirror of
https://github.com/gesellix/Bose-SoundTouch.git
synced 2026-08-19 09:06:14 +00:00
Replays app's commit-1 architectural restructure onto current main — mechanical move only, behaviour preserved verbatim. main.go shrinks from 333 to ~190 lines; the binary now orchestrates lifecycle and flag handling, the package owns the WebApp's responsibilities. Moves (no logic change vs the previous main.go bodies): main.go addDevice → (*WebApp).AddDeviceByHost in discovery.go main.go discoverDevices → (*WebApp).DiscoverDevices in discovery.go main.go setupRoutes → (*WebApp).Mount(r, ds) in mount.go inline serveIndex closure → (*WebApp).serveIndex in mount.go New helper: soundtouchweb.NewDiscoveryService(interfaceName) wraps config.LoadFromEnv + cfg adjustments + NewUnifiedDiscoveryService. Single source of truth for the web UI's discovery settings; identical to the inline wiring main.go used to do. main.go still owns (kept verbatim, post-base on main): - --port / --bind / --interface / --devices flags - resolveBindAddr (NIC-name → IP resolution for --bind) - defaultDiscoveryInterface (--bind ↔ --interface defaulting) - Startup goroutine sequence: broadcast start → preseed loop (AddDeviceByHost for each --devices entry) → DiscoverDevices → broadcast complete + device list - http.ListenAndServe Behaviour parity checklist: - Routes registered: identical set (see Mount). /api/discover still reuses the startup discoveryService instance, same as before. - Preseeded --devices still added BEFORE the mDNS/UPnP sweep, so the UI doesn't briefly show empty for hosts that come from --devices. - Discovery interface still pinned via --interface (or inherited from --bind), threaded through NewDiscoveryService. - Static FS still served at /static/*, SPA fallback at / /devices /device/* still hits the same index.html. go build ./... clean. go test ./... clean (only pre-existing TestDocsConsistency fails, untracked-file issue, unrelated). golangci-lint run ./... 0 issues. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>