Improve config parsing and intialization

This commit is contained in:
Jon Staab
2025-09-29 13:37:57 -07:00
parent 001771cb6c
commit 54a55da390
8 changed files with 166 additions and 146 deletions
+12 -3
View File
@@ -20,8 +20,17 @@ func main() {
port := zooid.Env("PORT")
srv := &http.Server{
Addr: fmt.Sprintf(":%s", port),
Handler: http.HandlerFunc(zooid.ServeHTTP),
Addr: fmt.Sprintf(":%s", port),
Handler: http.HandlerFunc(
func(w http.ResponseWriter, r *http.Request) {
instance, exists := zooid.Dispatch(r.Host)
if exists {
instance.Relay.ServeHTTP(w, r)
} else {
http.Error(w, "Not Found", http.StatusNotFound)
}
},
),
}
go func() {
@@ -31,7 +40,7 @@ func main() {
}
}()
go zooid.MonitorInstances()
go zooid.Start()
<-shutdown