2fas-server/internal/common/http/request.go

16 lines
292 B
Go
Raw Permalink Normal View History

2022-12-31 10:22:38 +01:00
package http
import (
"net/http"
2022-12-31 10:22:38 +01:00
2024-03-16 19:05:21 +01:00
"github.com/gin-gonic/gin"
2022-12-31 10:22:38 +01:00
)
func BodySizeLimitMiddleware(requestBytesLimit int64) gin.HandlerFunc {
return func(c *gin.Context) {
var w http.ResponseWriter = c.Writer
c.Request.Body = http.MaxBytesReader(w, c.Request.Body, requestBytesLimit)
}
}