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

Method handlePutLocalDoc

rest/doc_api.go:869–887  ·  view source on GitHub ↗

HTTP handler for a PUT of a _local document

()

Source from the content-addressed store, hash-verified

867
868// HTTP handler for a PUT of a _local document
869func (h *handler) handlePutLocalDoc() error {
870 docid := h.PathVar("docid")
871 localDocID := db.LocalDocPrefix + docid
872
873 body, err := h.readJSON()
874 if err != nil {
875 return err
876 }
877
878 revid, isNewDoc, err := h.collection.PutSpecial(db.DocTypeLocal, docid, body)
879 if err != nil {
880 return err
881 }
882
883 auditEventForDocumentUpsert(h.ctx(), localDocID, revid, isNewDoc)
884
885 h.writeRawJSONStatus(http.StatusCreated, []byte(`{"id":`+base.ConvertToJSONString(localDocID)+`,"ok":true,"rev":"`+revid+`"}`))
886 return nil
887}
888
889func auditEventForDocumentUpsert(ctx context.Context, docid string, revid string, isNewDoc bool) {
890 auditEvent := base.AuditIDDocumentUpdate

Callers

nothing calls this directly

Calls 7

PathVarMethod · 0.95
readJSONMethod · 0.95
ctxMethod · 0.95
writeRawJSONStatusMethod · 0.95
ConvertToJSONStringFunction · 0.92
PutSpecialMethod · 0.80

Tested by

no test coverage detected