The code and data behind xeiaso.net
5
fork

Configure Feed

Select the types of activity you want to include in your feed.

internal: add middleware to track the use of accept-encoding headers

Signed-off-by: Xe Iaso <me@xeiaso.net>

Xe Iaso f7367657 8ef825b0

+24
+1
cmd/xesite/main.go
··· 120 120 var h http.Handler = mux 121 121 h = internal.ClackSet(fs.Clacks()).Middleware(h) 122 122 h = internal.CacheHeader(h) 123 + h = internal.AcceptEncodingMiddleware(h) 123 124 124 125 slog.Info("starting server", "bind", *bind) 125 126 log.Fatal(http.Serve(ln, h))
+23
internal/accept_encoding.go
··· 1 + package internal 2 + 3 + import ( 4 + "expvar" 5 + "net/http" 6 + 7 + "tailscale.com/metrics" 8 + ) 9 + 10 + var ( 11 + acceptEncodings = &metrics.LabelMap{Label: "encoding"} 12 + ) 13 + 14 + func init() { 15 + expvar.Publish("gauge_xesite_accept_encoding", acceptEncodings) 16 + } 17 + 18 + func AcceptEncodingMiddleware(next http.Handler) http.Handler { 19 + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 20 + acceptEncodings.Add(r.Header.Get("Accept-Encoding"), 1) 21 + next.ServeHTTP(w, r) 22 + }) 23 + }