erFunc(func(w http.ResponseWriter, r *http.Request) { r.Body = http.MaxBytesReader(w, r.Body, MaxRequestBodySize) next.ServeHTTP(w, r) }) } } Pretty simple! The next question was obvious: how do I test this? I need to create an http.Request with a body that is larger than 4KB. I could probably do this by creating a bytes.Buffer that is bigger than the limit. That being said, perhaps there is a more creative way to solve this problem using Go’s io.Reader interface."><meta property="og:locale" content="en">