blob: 25fd14b46ed045e75660472c95dd0601380aec40 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
package internal
import (
"encoding/json"
"log/slog"
"net/http"
"runtime/debug"
"within.website/x"
)
func init() {
http.HandleFunc("/.within/debug/buildinfo", func(w http.ResponseWriter, r *http.Request) {
bi, ok := debug.ReadBuildInfo()
if !ok {
slog.Error("can't read build info")
http.Error(w, "no build info available", http.StatusInternalServerError)
return
}
if err := json.NewEncoder(w).Encode(struct {
BuildInfo *debug.BuildInfo `json:"build_info"`
Version string `json:"version"`
}{bi, x.Version}); err != nil {
slog.Error("can't encode build info", "err", err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
})
}
|