From 15d5db6e71766ff4dd9d44c2f2739dd39f01c924 Mon Sep 17 00:00:00 2001 From: NHAS Date: Sun, 11 Jun 2023 21:59:58 +1200 Subject: [PATCH] Add /status/?routes=true url param to just return routes for easy replacement --- internal/webserver/web.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/internal/webserver/web.go b/internal/webserver/web.go index 8828b4dc..f4219317 100644 --- a/internal/webserver/web.go +++ b/internal/webserver/web.go @@ -565,6 +565,15 @@ func status(w http.ResponseWriter, r *http.Request) { http.Error(w, "Server Error", 500) } + w.Header().Set("Content-Disposition", "attachment; filename=acl") + + if r.URL.Query().Get("routes") == "true" { + w.Header().Set("Content-Type", "text/plain") + w.Write([]byte(strings.Join(routes, ", "))) + return + } + + w.Header().Set("Content-Type", "application/json") status := struct { IsAuthorised bool Routes []string @@ -573,9 +582,6 @@ func status(w http.ResponseWriter, r *http.Request) { Routes: routes, } - w.Header().Set("Content-Disposition", "attachment; filename=acl") - w.Header().Set("Content-Type", "application/json") - result, err := json.Marshal(&status) if err != nil { log.Println(user.Username, remoteAddress, "error marshalling status")