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

Method readSanitizeDbConfigJSON

rest/handler.go:1387–1396  ·  view source on GitHub ↗

readSanitizeJSONInto reads and sanitizes a JSON request body and returns raw bytes and DbConfig. Expands environment variables (if any) referenced in the config.

()

Source from the content-addressed store, hash-verified

1385// readSanitizeJSONInto reads and sanitizes a JSON request body and returns raw bytes and DbConfig.
1386// Expands environment variables (if any) referenced in the config.
1387func (h *handler) readSanitizeDbConfigJSON() ([]byte, *DbConfig, error) {
1388 var config DbConfig
1389 rawBytes, err := h.readSanitizeJSON(&config)
1390 if err != nil {
1391 if errors.Cause(base.WrapJSONUnknownFieldErr(err)) == base.ErrUnknownField {
1392 err = base.HTTPErrorf(http.StatusBadRequest, "JSON Unknown Field: %s", err.Error())
1393 }
1394 }
1395 return rawBytes, &config, err
1396}
1397
1398// Reads & parses the request body, handling either JSON or multipart.
1399func (h *handler) readDocument() (db.Body, error) {

Callers 2

handleCreateDBMethod · 0.95
handlePutDbConfigMethod · 0.95

Calls 4

readSanitizeJSONMethod · 0.95
WrapJSONUnknownFieldErrFunction · 0.92
HTTPErrorfFunction · 0.92
ErrorMethod · 0.45

Tested by

no test coverage detected