Rename API endpoints to /tendrils/api/*, detect SSE via Accept header

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Ian Gulliver
2026-01-30 22:31:58 -08:00
parent 98c7fc75b7
commit d63b8192d2
4 changed files with 10 additions and 7 deletions

View File

@@ -47,9 +47,8 @@ func (t *Tendrils) startHTTPServer() {
}
mux := http.NewServeMux()
mux.HandleFunc("/api/status", t.handleAPIStatus)
mux.HandleFunc("/api/status/stream", t.handleAPIStatusStream)
mux.HandleFunc("/api/errors/clear", t.handleClearError)
mux.HandleFunc("/tendrils/api/status", t.handleAPIStatus)
mux.HandleFunc("/tendrils/api/errors/clear", t.handleClearError)
mux.Handle("/", noCacheHandler(http.FileServer(http.Dir("static"))))
log.Printf("[https] listening on :443")
@@ -122,6 +121,10 @@ func ensureCert() error {
}
func (t *Tendrils) handleAPIStatus(w http.ResponseWriter, r *http.Request) {
if r.Header.Get("Accept") == "text/event-stream" {
t.handleAPIStatusStream(w, r)
return
}
w.Header().Set("Content-Type", "application/json; charset=utf-8")
data, err := t.GetStatusJSON()
if err != nil {