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

Function decodeJSONWithLimit

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

3224// default cap is too small — but always pass an explicit cap, never
3225// remove the wrapper.
3226func decodeJSONWithLimit(r *http.Request, v interface{}, maxBytes int64) error {
3227 raw, err := readBodyForDecode(r, maxBytes)
3228 if err != nil {
3229 return fmt.Errorf("invalid JSON: %w", err)
3230 }
3231 return decodeJSONBytes(raw, v)
3232}
3233
3234// decodeJSONRepairingNUL is decodeJSONWithLimit with exactly one difference,
3235// and the difference is deliberately NOT a bypass (DOC-2823 S3, BUG-2810).

Callers 6

handleSendChatMessageMethod · 0.85
decodeJSONFunction · 0.85
handleImportWorkspaceMethod · 0.85
appRedeemContextMethod · 0.85

Calls 2

readBodyForDecodeFunction · 0.85
decodeJSONBytesFunction · 0.85

Tested by 1