I chose to limit request bodies to 4KB.
Go&rsquo;s <a href=https://pkg.go.dev/net/http class=external-link target=_blank rel=noopener>net/http</a> package already includes a utility for this (called <a href=https://pkg.go.dev/net/http#MaxBytesReader class=external-link target=_blank rel=noopener>MaxBytesReader</a>) which makes writing the middleware quite simple.
Note that the way I write middleware is heavily inspired by Mat Ryer&rsquo;s <a href=https://medium.com/@matryer/writing-middleware-in-golang-and-