diff options
Diffstat (limited to 'cmd/uncle-ted/main.go')
| -rw-r--r-- | cmd/uncle-ted/main.go | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/cmd/uncle-ted/main.go b/cmd/uncle-ted/main.go index 1f7d0e0..7998a40 100644 --- a/cmd/uncle-ted/main.go +++ b/cmd/uncle-ted/main.go @@ -1,7 +1,7 @@ package main import ( - _ "embed" + "embed" "flag" "log" "log/slog" @@ -15,18 +15,26 @@ var ( //go:embed bomb.txt.gz.gz kaboom []byte + + //go:embed bee-movie.txt + static embed.FS ) func main() { internal.HandleStartup() - http.HandleFunc("/", defenseHandler) + http.HandleFunc("/bee-movie", beeMovie) + http.HandleFunc("/gzip-bomb", gzipBomb) slog.Info("started up", "url", "http://localhost"+*bind) log.Fatal(http.ListenAndServe(*bind, nil)) } -func defenseHandler(w http.ResponseWriter, r *http.Request) { +func beeMovie(w http.ResponseWriter, r *http.Request) { + http.ServeFileFS(w, r, static, "bee-movie.txt") +} + +func gzipBomb(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "text/plain") w.Header().Set("Content-Encoding", "gzip") w.Header().Set("Transfer-Encoding", "gzip") |
