aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorXe Iaso <me@xeiaso.net>2023-11-23 10:12:00 -0500
committerXe Iaso <me@xeiaso.net>2023-11-23 10:12:00 -0500
commit1f5af7f2cb669e8cbdad90b59b3eb1d5cf375fb0 (patch)
tree6437853f6de09129d316bd6020ca4b148b00724e /cmd
parent79604c40ed686b38f092ddc7d5f1c5b773837e61 (diff)
downloadx-1f5af7f2cb669e8cbdad90b59b3eb1d5cf375fb0.tar.xz
x-1f5af7f2cb669e8cbdad90b59b3eb1d5cf375fb0.zip
cmd/xedn: add cdn-cgi/wtf
Signed-off-by: Xe Iaso <me@xeiaso.net>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/xedn/fly.toml2
-rw-r--r--cmd/xedn/imgoptimize.go2
-rw-r--r--cmd/xedn/main.go23
3 files changed, 20 insertions, 7 deletions
diff --git a/cmd/xedn/fly.toml b/cmd/xedn/fly.toml
index 2871975..45fd4b3 100644
--- a/cmd/xedn/fly.toml
+++ b/cmd/xedn/fly.toml
@@ -2,6 +2,8 @@ app = "xedn"
kill_signal = "SIGINT"
kill_timeout = "5s"
+swap_size_mb = 512
+
[experimental]
auto_rollback = true
diff --git a/cmd/xedn/imgoptimize.go b/cmd/xedn/imgoptimize.go
index a28a492..a0c1072 100644
--- a/cmd/xedn/imgoptimize.go
+++ b/cmd/xedn/imgoptimize.go
@@ -166,7 +166,7 @@ func (ois *OptimizedImageServer) ResizeTo(widthPixels int, character, mood, form
return nil, err
}
default:
- return nil, fmt.Errorf("I don't know how to render to %s yet, sorry", format)
+ return nil, fmt.Errorf("i don't know how to render to %s yet, sorry", format)
}
OISFileConversions.Add(format, 1)
diff --git a/cmd/xedn/main.go b/cmd/xedn/main.go
index 9d6cf83..5e7e2cd 100644
--- a/cmd/xedn/main.go
+++ b/cmd/xedn/main.go
@@ -3,8 +3,10 @@ package main
import (
_ "embed"
+ "encoding/json"
"expvar"
"flag"
+ "fmt"
"image/png"
"io"
"log"
@@ -169,12 +171,7 @@ func main() {
mux.HandleFunc("/", http.FileServer(http.Dir(filepath.Join(*dir, "uploud"))).ServeHTTP)
- go http.ListenAndServe(*metricsAddr, tsweb.StdHandler(tsweb.ReturnHandlerFunc(func(w http.ResponseWriter, r *http.Request) error {
- mux.ServeHTTP(w, r)
- return nil
- }), tsweb.HandlerOptions{
- Logf: log.Printf,
- }))
+ go http.ListenAndServe(*metricsAddr, mux)
}
cdn := http.NewServeMux()
@@ -193,6 +190,20 @@ func main() {
cdn.Handle("/sticker/", ois)
cdn.Handle("/avatar/", sd)
cdn.Handle("/static/", http.FileServer(http.Dir(*staticDir)))
+ cdn.HandleFunc("/cgi-cdn/wtf", func(w http.ResponseWriter, r *http.Request) {
+ fmt.Fprintln(w, "Hello, here is what I know about you:")
+ fmt.Fprintln(w)
+ fmt.Fprintln(w, "HTTP headers from your client:")
+ fmt.Fprintln(w)
+
+ enc := json.NewEncoder(w)
+ enc.SetIndent("", " ")
+ enc.Encode(r.Header)
+
+ fmt.Fprintln(w)
+ fmt.Fprintf(w, "I am XeDN %s (instance ID %s) running %s\n", os.Getenv("FLY_REGION"), os.Getenv("FLY_ALLOC_ID"), os.Args[0])
+ fmt.Fprintln(w)
+ })
hdlr := func(w http.ResponseWriter, r *http.Request) {
etagLock.RLock()