package http_internal import ( "net/http" loadaverage "rpi5-health/internal/load_average" "rpi5-health/internal/memory" "rpi5-health/internal/processor" "rpi5-health/internal/temperature" "rpi5-health/internal/uptime" ) type AppServer struct { srv *http.Server mux *http.ServeMux } // To be sent to the client type ServerStatistics struct { LoadAvgInfo loadaverage.LoadAverageInformation `json:"load_average"` MemoryInfo memory.MemoryInformation `json:"memory_info"` ProcessorInfo processor.ProcessorInformation `json:"processor_info"` TemperatureInfo temperature.TemperatureInformation `json:"temperature_info"` UptimeInfo uptime.UptimeInformation `json:"uptime_info"` } func NewAppServer() *AppServer { mux := http.NewServeMux() fs := http.FileServer(http.Dir("web/")) mux.Handle("/", fs) srv := &http.Server{ Addr: "localhost:1234", Handler: mux, } return &AppServer{ srv: srv, mux: mux, } } func (srv *AppServer) Start() { srv.srv.ListenAndServe() } func (srv *AppServer) RegisterRoute(endpoint string, handler http.HandlerFunc) { srv.mux.HandleFunc(endpoint, handler) }