MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / CheckRequestSize

Function CheckRequestSize

db/functions.go:85–91  ·  view source on GitHub ↗

UTILITIES Returns an HTTP 413 error if `maxSize` is non-nil and less than `actualSize`.

(actualSize T, maxSize *int)

Source from the content-addressed store, hash-verified

83
84// Returns an HTTP 413 error if `maxSize` is non-nil and less than `actualSize`.
85func 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.
94func EstimateSizeOfJSON(args any) int {

Callers 2

getFunctionArgsMethod · 0.92
parseJsonBodyMethod · 0.85

Calls 1

HTTPErrorfFunction · 0.92

Tested by

no test coverage detected