feat(web): rewrite tunnel monitor preview

This commit is contained in:
2026-05-03 23:53:32 -04:00
parent 9efc2b0494
commit c9304ea1cf
9 changed files with 593 additions and 313 deletions

View File

@@ -26,6 +26,7 @@ func (s *WebServer) Start(ctx context.Context) error {
rootMux := http.NewServeMux()
rootMux.HandleFunc("/", s.handleRoot)
rootMux.HandleFunc("/assets/network.js", s.handleNetworkScript)
rootMux.HandleFunc("/stream", s.handleStream)
s.server = &http.Server{
@@ -85,6 +86,11 @@ func (s *WebServer) handleStream(w http.ResponseWriter, r *http.Request) {
}
func (s *WebServer) handleRoot(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/html")
_ = pages.NetworkPage().Render(w)
w.Header().Set("Content-Type", "text/html; charset=utf-8")
_, _ = w.Write([]byte(pages.NetworkHTML()))
}
func (s *WebServer) handleNetworkScript(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/javascript; charset=utf-8")
_, _ = w.Write([]byte(pages.NetworkScript()))
}