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

Function decodeJSON

internal/server/server.go:3218–3220  ·  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

3216// multi-GB JSON blob — without this, json.NewDecoder.Decode happily
3217// streams the whole body into a single allocation.
3218func decodeJSON(r *http.Request, v interface{}) error {
3219 return decodeJSONWithLimit(r, v, defaultJSONBodyLimit)
3220}
3221
3222// decodeJSONWithLimit is the size-configurable variant. Use this for
3223// endpoints that accept large payloads (e.g. bulk-import) where the

Callers 15

handleBuiltinUpdateMethod · 0.85
handleImportURLMethod · 0.85
handleItemsSortOrderMethod · 0.85
handleInviteMemberMethod · 0.85
handleCreateDocumentMethod · 0.85
handleUpdateDocumentMethod · 0.85
handleMarkChatReadMethod · 0.85

Calls 1

decodeJSONWithLimitFunction · 0.85