MCPcopy
hub / github.com/pocketbase/pocketbase / BodyLimit

Function BodyLimit

apis/middlewares_body_limit.go:27–40  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

25// Otherwise, if the request body size exceeds the configured limitBytes,
26// it sends 413 error response.
27func 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
42func dynamicCollectionBodyLimit(collectionPathParam string) *hook.Handler[*core.RequestEvent] {
43 if collectionPathParam == "" {

Callers 3

TestBodyLimitMiddlewareFunction · 0.92
bindBackupApiFunction · 0.85
NewRouterFunction · 0.85

Calls 2

applyBodyLimitFunction · 0.85
NextMethod · 0.65

Tested by 1

TestBodyLimitMiddlewareFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…