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

Method handleGetDocReplicator2

rest/doc_api.go:213–240  ·  view source on GitHub ↗
(docid, revOrCV string)

Source from the content-addressed store, hash-verified

211}
212
213func (h *handler) handleGetDocReplicator2(docid, revOrCV string) error {
214 if !base.IsEnterpriseEdition() {
215 return base.HTTPErrorf(http.StatusNotImplemented, "replicator2 endpoints are only supported in EE")
216 }
217
218 rev, err := h.collection.GetRev(h.ctx(), docid, revOrCV, true, nil)
219 if err != nil {
220 return err
221 }
222
223 // Stamp _attachments into message to match BLIP sendRevision behaviour
224 bodyBytes := rev.BodyBytes
225 if len(rev.Attachments) > 0 {
226 bodyBytes, err = base.InjectJSONProperties(bodyBytes, base.KVPair{Key: db.BodyAttachments, Val: rev.Attachments})
227 if err != nil {
228 return err
229 }
230 }
231
232 h.setHeader("Content-Type", "application/json")
233 _, _ = h.response.Write(bodyBytes)
234 h.db.DbStats.Database().NumDocReadsRest.Add(1)
235 base.Audit(h.ctx(), base.AuditIDDocumentRead, base.AuditFields{
236 base.AuditFieldDocID: docid,
237 base.AuditFieldDocVersion: rev.RevID,
238 })
239 return nil
240}
241
242// HTTP handler for a GET of a specific doc attachment
243func (h *handler) handleGetAttachment() error {

Callers 1

handleGetDocMethod · 0.95

Calls 10

ctxMethod · 0.95
setHeaderMethod · 0.95
IsEnterpriseEditionFunction · 0.92
HTTPErrorfFunction · 0.92
InjectJSONPropertiesFunction · 0.92
AuditFunction · 0.92
GetRevMethod · 0.80
WriteMethod · 0.45
AddMethod · 0.45
DatabaseMethod · 0.45

Tested by

no test coverage detected