BodyLimit returns a middleware handler that changes the default request body size limit. If limitBytes <= 0, no limit is applied. Otherwise, if the request body size exceeds the configured limitBytes, it sends 413 error response.
(limitBytes int64)
| 25 | // Otherwise, if the request body size exceeds the configured limitBytes, |
| 26 | // it sends 413 error response. |
| 27 | func BodyLimit(limitBytes int64) *hook.Handler[*core.RequestEvent] { |
| 28 | return &hook.Handler[*core.RequestEvent]{ |
| 29 | Id: DefaultBodyLimitMiddlewareId, |
| 30 | Priority: DefaultBodyLimitMiddlewarePriority, |
| 31 | Func: func(e *core.RequestEvent) error { |
| 32 | err := applyBodyLimit(e, limitBytes) |
| 33 | if err != nil { |
| 34 | return err |
| 35 | } |
| 36 | |
| 37 | return e.Next() |
| 38 | }, |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | func dynamicCollectionBodyLimit(collectionPathParam string) *hook.Handler[*core.RequestEvent] { |
| 43 | if collectionPathParam == "" { |
searching dependent graphs…