MCPcopy Create free account
hub / github.com/PerpetualSoftware/pad / decodeJSON

Function decodeJSON

internal/server/server.go:1839–1841  ·  view source on GitHub ↗

2 MiB decodeJSON reads and unmarshals the JSON body into v. Wraps the body in http.MaxBytesReader so an attacker can't exhaust memory by POSTing a multi-GB JSON blob — without this, json.NewDecoder.Decode happily streams the whole body into a single allocation.

(r *http.Request, v interface{})

Source from the content-addressed store, hash-verified

1837// multi-GB JSON blob — without this, json.NewDecoder.Decode happily
1838// streams the whole body into a single allocation.
1839func decodeJSON(r *http.Request, v interface{}) error {
1840 return decodeJSONWithLimit(r, v, defaultJSONBodyLimit)
1841}
1842
1843// decodeJSONWithLimit is the size-configurable variant. Use this for
1844// endpoints that accept large payloads (e.g. bulk-import) where the

Calls 1

decodeJSONWithLimitFunction · 0.85