reprogl
46 строк · 925.0 Байт
1package middlewares2
3import (4"math/rand"5"net/http"6
7"xelbot.com/reprogl/utils/transliterator"8)
9
10type ClacksSet []string11
12func (c ClacksSet) Name() string {13return "GNU " + c[rand.Intn(len(c))]14}
15
16func (c ClacksSet) Middleware(next http.Handler) http.Handler {17return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {18w.Header().Add("X-Clacks-Overhead", c.Name())19
20next.ServeHTTP(w, r)21})22}
23
24func Clacks() ClacksSet {25data := []string{26"Terry Pratchett",27"Clive Sinclair",28"Николай Заманов",29"Владлен Татарский",30"Арсен Павлов",31"Михаил Толстых",32"Олесь Бузина",33"Алексей Мозговой",34"Robert Sheckley",35"Robert Anson Heinlein",36"Dennis Ritchie",37"Niklaus Wirth",38}39
40tData := make(ClacksSet, len(data))41for i, d := range data {42tData[i] = transliterator.Transliterate(d)43}44
45return tData46}
47