aboutsummaryrefslogtreecommitdiff
path: root/internal/clacks.go
blob: 19e15b90cd04fa3f546affa2e9c87fed783db786 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package internal

import (
	"math/rand"
	"net/http"
)

type ClackSet []string

func (cs ClackSet) Name() string {
	return "GNU " + cs[rand.Intn(len(cs))]
}

func (cs ClackSet) Middleware(next http.Handler) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		w.Header().Add("X-Clacks-Overhead", cs.Name())

		next.ServeHTTP(w, r)
	})
}