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