status: include service status and GOARCH in HTTP headers

This will come in handy in https://github.com/gokrazy/breakglass
This commit is contained in:
Michael Stapelberg 2020-05-25 09:29:58 +02:00
parent 727ba0f371
commit 7e02056689

View File

@ -9,6 +9,7 @@ import (
"log" "log"
"net/http" "net/http"
"path/filepath" "path/filepath"
"runtime"
"sort" "sort"
"strconv" "strconv"
"strings" "strings"
@ -175,6 +176,12 @@ func initStatus(services []*service) {
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)
return return
} }
status := "started"
if svc.Stopped() {
status = "stopped"
}
w.Header().Set("X-Gokrazy-Status", status)
w.Header().Set("X-Gokrazy-GOARCH", runtime.GOARCH)
io.Copy(w, &buf) io.Copy(w, &buf)
}) })