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

Method readDocument

rest/handler.go:1399–1410  ·  view source on GitHub ↗

Reads & parses the request body, handling either JSON or multipart.

()

Source from the content-addressed store, hash-verified

1397
1398// Reads & parses the request body, handling either JSON or multipart.
1399func (h *handler) readDocument() (db.Body, error) {
1400 contentType, attrs, _ := mime.ParseMediaType(h.rq.Header.Get("Content-Type"))
1401 switch contentType {
1402 case "", "application/json":
1403 return h.readJSON()
1404 case "multipart/related":
1405 reader := multipart.NewReader(h.requestBody, attrs["boundary"])
1406 return ReadMultipartDocument(reader)
1407 default:
1408 return nil, base.HTTPErrorf(http.StatusUnsupportedMediaType, "Invalid content type %s", contentType)
1409 }
1410}
1411
1412func (h *handler) requestAccepts(mimetype string) bool {
1413 accept := h.rq.Header.Get("Accept")

Callers 2

handlePutDocMethod · 0.95
handlePostDocMethod · 0.95

Calls 4

readJSONMethod · 0.95
HTTPErrorfFunction · 0.92
ReadMultipartDocumentFunction · 0.85
GetMethod · 0.45

Tested by

no test coverage detected