Add remove button for unreachable nodes not in config

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Ian Gulliver
2026-02-02 11:18:06 -08:00
parent d4e7a8a9b7
commit eff2635725
7 changed files with 164 additions and 4 deletions

23
http.go
View File

@@ -49,6 +49,7 @@ func (t *Tendrils) startHTTPServer() {
mux := http.NewServeMux()
mux.HandleFunc("/tendrils/api/status", t.handleAPIStatus)
mux.HandleFunc("/tendrils/api/errors/clear", t.handleClearError)
mux.HandleFunc("/tendrils/api/nodes/remove", t.handleRemoveNode)
mux.Handle("/", noCacheHandler(http.FileServer(http.Dir("static"))))
log.Printf("[https] listening on :443")
@@ -181,6 +182,28 @@ func (t *Tendrils) handleClearError(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
}
func (t *Tendrils) handleRemoveNode(w http.ResponseWriter, r *http.Request) {
if r.Method != "POST" {
http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
return
}
id := r.URL.Query().Get("id")
if id == "" {
http.Error(w, "missing id parameter", http.StatusBadRequest)
return
}
if err := t.nodes.RemoveNodeByID(id); err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
log.Printf("removed node %s", id)
t.NotifyUpdate()
w.WriteHeader(http.StatusOK)
}
func (t *Tendrils) handleAPIStatusStream(w http.ResponseWriter, r *http.Request) {
flusher, ok := w.(http.Flusher)
if !ok {