SSE impl done

This commit is contained in:
lin committed 2026-10-06 15:49:19 +02:00
1 parent 88b5ff98cd
commit cad4ae65f7
4 files changed
+96 -3

No files matched your search

+21 -1
View File
@@ -1,12 +1,28 @@
package http_internal
import "net/http"
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()
@@ -28,3 +44,7 @@ func NewAppServer() *AppServer {
func (srv *AppServer) Start() {
srv.srv.ListenAndServe()
}
func (srv *AppServer) RegisterRoute(endpoint string, handler http.HandlerFunc) {
srv.mux.HandleFunc(endpoint, handler)
}