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

Function decodeJSONWithLimit

internal/server/server.go:3319–3325  ·  view source on GitHub ↗

decodeJSONWithLimit is the size-configurable variant. Use this for endpoints that accept large payloads (e.g. bulk-import) where the default cap is too small — but always pass an explicit cap, never remove the wrapper.

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

Source from the content-addressed store, hash-verified

3317// default cap is too small — but always pass an explicit cap, never
3318// remove the wrapper.
3319func decodeJSONWithLimit(r *http.Request, v interface{}, maxBytes int64) error {
3320 raw, err := readBodyForDecode(r, maxBytes)
3321 if err != nil {
3322 return fmt.Errorf("invalid JSON: %w", err)
3323 }
3324 return decodeJSONBytes(raw, v)
3325}
3326
3327// repairBodyNULEscapes repairs a JSON body the way the GATE reads it, and
3328// returns how many values it changed.

Callers 6

handleSendChatMessageMethod · 0.85
decodeJSONFunction · 0.85
appRedeemContextMethod · 0.85
handlePendingLinkPostMethod · 0.85

Calls 2

readBodyForDecodeFunction · 0.85
decodeJSONBytesFunction · 0.85

Tested by 1