func NewMaxBodyBytesHandler(limit int64) func(http.Handler) http.Handler {
	return func(h http.Handler) http.Handler {
		return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
			if r.ContentLength > limit {
				RequestEntityTooLarge(w, nil)
				return
			}
			r.Body = http.MaxBytesReader(w, r.Body, limit)
			h.ServeHTTP(w, r)
		})
	}
}
// NewMaxBodyBytesHandler is an http middleware constructor that limits the
// maximal number of bytes that can be read from the request body. When a body
// is read, the error can be handled with a helper function HandleBodyReadError
// in order to respond with Request Entity Too Large response.
// See TestNewMaxBodyBytesHandler as an example.
NewMaxBodyBytesHandler is an http middleware constructor that limits the
maximal number of bytes that can be read from the request body. When a body
is read, the error can be handled with a helper function HandleBodyReadError
in order to respond with Request Entity Too Large response.
See TestNewMaxBodyBytesHandler as an example.
// NewMaxBodyBytesHandler is an http middleware constructor that limits the // maximal number of bytes that can be read from the request body . When a body // is read the error can be handled with a helper function HandleBodyReadError // in order to respond with Request Entity Too Large response . // See TestNewMaxBodyBytesHandler as an example .
func NewMaxBodyBytesHandler(limit int64) func(http.Handler) http.Handler {
	return func(h http.Handler) http.Handler {
		return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
			if r.ContentLength > limit {
				RequestEntityTooLarge(w, nil)
				return
			}
			r.Body = http.MaxBytesReader(w, r.Body, limit)
			h.ServeHTTP(w, r)
		})
	}
}
func NewMaxBodyBytesHandler ( limit int64 ) func ( http . Handler ) http . Handler { return func ( h http . Handler ) http . Handler { return http . HandlerFunc ( func ( w http . ResponseWriter , r * http . Request ) { if r . ContentLength > limit { RequestEntityTooLarge ( w , nil ) return } r . Body = http . MaxBytesReader ( w , r . Body , limit ) h . ServeHTTP ( w , r ) } ) } }
NewMaxBodyBytesHandler is an http middleware constructor that limits the
maximal number of bytes that can be read from the request body.
NewMaxBodyBytesHandler is an http middleware constructor that limits the maximal number of bytes that can be read from the request body .