Skip to content

Commit

Permalink
Add /status/?routes=true url param to just return routes for easy rep…
Browse files Browse the repository at this point in the history
…lacement
  • Loading branch information
NHAS committed Jun 11, 2023
1 parent 7241f48 commit 15d5db6
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions internal/webserver/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
Expand Down

0 comments on commit 15d5db6

Please sign in to comment.