aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorXe Iaso <me@xeiaso.net>2023-11-08 20:46:34 -0500
committerXe Iaso <me@xeiaso.net>2023-11-08 20:48:31 -0500
commit0d445c0d527448160eb5e977eacdd7498add117c (patch)
tree2fde48f56dc8d47bd196c1ceb848eb8d3832b8a3 /cmd
parent3bed9ddab0207f8deab48a27b345540f8a3199f0 (diff)
downloadx-0d445c0d527448160eb5e977eacdd7498add117c.tar.xz
x-0d445c0d527448160eb5e977eacdd7498add117c.zip
cmd/xedn: fly region annotation middleware
Signed-off-by: Xe Iaso <me@xeiaso.net>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/xedn/main.go14
1 files changed, 13 insertions, 1 deletions
diff --git a/cmd/xedn/main.go b/cmd/xedn/main.go
index 3ad0624..a6762a8 100644
--- a/cmd/xedn/main.go
+++ b/cmd/xedn/main.go
@@ -213,6 +213,18 @@ func main() {
http.Error(w, "wait, what, how did you do that?", http.StatusBadRequest)
})
+ var h http.Handler = topLevel
+ h = xffMW.Handler(h)
+ h = cors.Default().Handler(h)
+ h = FlyRegionAnnotation(h)
+
slog.Info("starting up", "addr", *addr)
- http.ListenAndServe(*addr, cors.Default().Handler(xffMW.Handler(topLevel)))
+ http.ListenAndServe(*addr, h)
+}
+
+func FlyRegionAnnotation(next http.Handler) http.Handler {
+ return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ w.Header().Set("Fly-Region", os.Getenv("FLY_REGION"))
+ next.ServeHTTP(w, r)
+ })
}