aboutsummaryrefslogtreecommitdiff
path: root/cmd/xedn/main.go
diff options
context:
space:
mode:
authorXe Iaso <me@xeiaso.net>2023-12-14 11:47:13 -0500
committerXe Iaso <me@xeiaso.net>2023-12-14 11:47:18 -0500
commite48204a5e494640a597d38bf0c23cc7e230bceb5 (patch)
treecdcd573e5d2647762015d9e369d81780174cfab3 /cmd/xedn/main.go
parentb5eda2067dcfc71bc48b4859993683baf81f8c21 (diff)
downloadx-e48204a5e494640a597d38bf0c23cc7e230bceb5.tar.xz
x-e48204a5e494640a597d38bf0c23cc7e230bceb5.zip
cmd/xedn: add cdn-cgi/wtf/json
Signed-off-by: Xe Iaso <me@xeiaso.net>
Diffstat (limited to 'cmd/xedn/main.go')
-rw-r--r--cmd/xedn/main.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/cmd/xedn/main.go b/cmd/xedn/main.go
index 5e7e2cd..8eabddb 100644
--- a/cmd/xedn/main.go
+++ b/cmd/xedn/main.go
@@ -205,6 +205,21 @@ func main() {
fmt.Fprintln(w)
})
+ cdn.HandleFunc("/cgi-cdn/wtf/json", func(w http.ResponseWriter, r *http.Request) {
+ enc := json.NewEncoder(w)
+ enc.SetIndent("", " ")
+
+ enc.Encode(map[string]any{
+ "headers": r.Header,
+ "your_ip": r.Header.Get("Fly-Client-Ip"),
+ "xedn": map[string]any{
+ "region": os.Getenv("FLY_REGION"),
+ "instance": os.Getenv("FLY_ALLOC_ID"),
+ "binary": os.Args[0],
+ },
+ })
+ })
+
hdlr := func(w http.ResponseWriter, r *http.Request) {
etagLock.RLock()
etag, ok := etags[r.URL.Path]