Added "WithMaxBytes" middleware
This commit is contained in:
@@ -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)
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user