A Go implementation of cookie-based bot blocking middleware that prevents non-human crawlers (AI bots, LLM scrapers) from accessing web content. The middleware wraps any http.Handler and works by presenting a simple checkbox form to visitors without a valid cookie. It hashes the User-Agent string using a configurable hash.Hash (e.g., HMAC-SHA256), sets a cookie upon form submission, and only allows requests through when the cookie value matches the hashed User-Agent. It skips non-HTML requests to avoid breaking images or RSS feeds. The author intentionally keeps it as copy-paste code rather than a published Go module, citing simplicity and low maintenance overhead.
2 Impressions