Added "WithMaxBytes" middleware

This commit is contained in:
Robin Dittmar
2026-07-20 20:12:45 +02:00
parent 10a34387ef
commit caf79e0dff
3 changed files with 14 additions and 2 deletions
+13
View File
@@ -0,0 +1,13 @@
package middleware
import "net/http"
func WithMaxBytes(limit int64) func(http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
r.Body = http.MaxBytesReader(w, r.Body, limit)
next.ServeHTTP(w, r)
})
}
}