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)
| 3224 | // default cap is too small — but always pass an explicit cap, never |
| 3225 | // remove the wrapper. |
| 3226 | func 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). |