aboutsummaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorXe Iaso <me@xeiaso.net>2023-07-29 14:13:50 -0400
committerXe Iaso <me@xeiaso.net>2023-07-29 14:13:50 -0400
commitb17f20f3e30c4a39033d210f2d86ffd005a9ea76 (patch)
tree9dbd85f9e7a1804674bf8c1b527a839493d0adf2 /internal
parent53adf0da54cf7e82f3d6e0163191b3c4d7669d75 (diff)
downloadx-b17f20f3e30c4a39033d210f2d86ffd005a9ea76.tar.xz
x-b17f20f3e30c4a39033d210f2d86ffd005a9ea76.zip
internal: more debug routes
Signed-off-by: Xe Iaso <me@xeiaso.net>
Diffstat (limited to 'internal')
-rw-r--r--internal/buildinfo.go26
-rw-r--r--internal/license.go10
2 files changed, 34 insertions, 2 deletions
diff --git a/internal/buildinfo.go b/internal/buildinfo.go
new file mode 100644
index 0000000..b3f7390
--- /dev/null
+++ b/internal/buildinfo.go
@@ -0,0 +1,26 @@
+package internal
+
+import (
+ "encoding/json"
+ "net/http"
+ "runtime/debug"
+
+ "golang.org/x/exp/slog"
+)
+
+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(bi); err != nil {
+ slog.Error("can't encode build info", "err", err)
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+ })
+}
diff --git a/internal/license.go b/internal/license.go
index bb4dc0b..7eead24 100644
--- a/internal/license.go
+++ b/internal/license.go
@@ -5,8 +5,8 @@ import (
"net/http"
"os"
- "within.website/x/cmd/license/licenses"
"go4.org/legal"
+ "within.website/x/cmd/license/licenses"
)
func init() {
@@ -17,10 +17,16 @@ func init() {
fmt.Fprintf(w, "Licenses for this program: %s\n", os.Args[0])
for _, li := range legal.Licenses() {
- fmt.Fprintln(w, li)
fmt.Fprintln(w)
+ fmt.Fprintln(w, "---")
+ fmt.Fprintln(w)
+ fmt.Fprintln(w, li)
}
+ fmt.Fprintln(w)
+ fmt.Fprintln(w, "---")
+ fmt.Fprintln(w)
+
fmt.Fprintln(w, "Be well, Creator.")
})
}