Add maxBytesLimit const
@@ -5,13 +5,18 @@ import (
"net/http"
)
+// maxBytesLimit is the max http request size, in bytes (see https://github.com/sensu/sensu-alpha-documentation/blob/master/97-FAQ.md)
+const (
+ maxBytesLimit = 512000
+)
+
// LimitRequest is an HTTP middleware that enforces request limits
type LimitRequest struct{}
// Then middleware
func (l LimitRequest) Then(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- r.Body = http.MaxBytesReader(w, r.Body, 512000)
+ r.Body = http.MaxBytesReader(w, r.Body, maxBytesLimit)
r.Header.Add("Content-Type", "application/x-www-form-urlencoded")
err := r.ParseForm()
if err != nil && err != io.EOF {
