feat: improve ENV variable overrides, introduce Node struct, refactoring

This commit is contained in:
2025-05-20 11:04:23 +02:00
parent bfc82870c3
commit d0a478d172
12 changed files with 210 additions and 149 deletions

View File

@@ -3,6 +3,7 @@ package http
import (
"context"
"encoding/json"
"log"
"net/http"
"time"
@@ -44,6 +45,18 @@ func (s *Server) WithClusterAgent(agent *cluster.Agent) *Server {
return s
}
func Up(appConfig *config.Config, clusterAgent *cluster.Agent) *Server {
srv := NewServer(appConfig)
srv.WithClusterAgent(clusterAgent)
srv.RegisterRoutes()
log.Printf("[INFO] Starting API server on %s", appConfig.Rcond.Addr)
if err := srv.Start(); err != nil {
log.Fatal(err)
}
return srv
}
func (s *Server) Start() error {
return s.srv.ListenAndServe()
}