UTILITIES Returns an HTTP 413 error if `maxSize` is non-nil and less than `actualSize`.
(actualSize T, maxSize *int)
| 83 | |
| 84 | // Returns an HTTP 413 error if `maxSize` is non-nil and less than `actualSize`. |
| 85 | func CheckRequestSize[T int | int64](actualSize T, maxSize *int) error { |
| 86 | if maxSize != nil && int64(actualSize) > int64(*maxSize) { |
| 87 | return base.HTTPErrorf(http.StatusRequestEntityTooLarge, "Arguments too large") |
| 88 | } else { |
| 89 | return nil |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | // Utility that returns a rough estimate of the original size of the JSON a value was parsed from. |
| 94 | func EstimateSizeOfJSON(args any) int { |
no test coverage detected