diff --git a/internal/control/control.go b/internal/control/control.go index 25a5a5e..e0cf0e8 100644 --- a/internal/control/control.go +++ b/internal/control/control.go @@ -1,6 +1,7 @@ package control import ( + _ "embed" "encoding/json" "net/http" "sync" @@ -10,6 +11,9 @@ import ( "github.com/jan/fm-rds-tx/internal/platform" ) +//go:embed ui.html +var uiHTML []byte + // TXController is an optional interface the Server uses to start/stop TX // and apply live config changes. type TXController interface { @@ -76,6 +80,7 @@ func (s *Server) SetDriver(drv platform.SoapyDriver) { func (s *Server) Handler() http.Handler { mux := http.NewServeMux() + mux.HandleFunc("/", s.handleUI) mux.HandleFunc("/healthz", s.handleHealth) mux.HandleFunc("/status", s.handleStatus) mux.HandleFunc("/dry-run", s.handleDryRun) @@ -91,6 +96,16 @@ func (s *Server) handleHealth(w http.ResponseWriter, _ *http.Request) { _ = json.NewEncoder(w).Encode(map[string]any{"ok": true}) } +func (s *Server) handleUI(w http.ResponseWriter, r *http.Request) { + if r.URL.Path != "/" { + http.NotFound(w, r) + return + } + w.Header().Set("Content-Type", "text/html; charset=utf-8") + w.Header().Set("Cache-Control", "no-cache") + w.Write(uiHTML) +} + func (s *Server) handleStatus(w http.ResponseWriter, _ *http.Request) { s.mu.RLock() cfg := s.cfg diff --git a/internal/control/ui.html b/internal/control/ui.html new file mode 100644 index 0000000..1a70e9c --- /dev/null +++ b/internal/control/ui.html @@ -0,0 +1,875 @@ + + +
+ + +