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

Method handleRevsDiff

rest/changes_api.go:45–74  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

43const feedTypeWebsocket = "websocket"
44
45func (h *handler) handleRevsDiff() error {
46 var input map[string][]string
47 err := h.readJSONInto(&input)
48 if err != nil {
49 return err
50 }
51
52 _, _ = h.response.Write([]byte("{"))
53 first := true
54 for docid, revs := range input {
55 missing, possible := h.collection.RevDiff(h.ctx(), docid, revs)
56 if missing != nil {
57 docOutput := map[string]interface{}{"missing": missing}
58 if possible != nil {
59 docOutput["possible_ancestors"] = possible
60 }
61 if !first {
62 _, _ = h.response.Write([]byte(",\n"))
63 }
64 first = false
65 _, _ = h.response.Write([]byte(fmt.Sprintf("%q:", docid)))
66 err = h.addJSON(docOutput)
67 if err != nil {
68 return err
69 }
70 }
71 }
72 _, _ = h.response.Write([]byte("}"))
73 return nil
74}
75
76// UpdateChangesOptionsFromQuery handles any changes POST requests that send parameters in the POST body AND in the query string. If any parameters
77// are present in the query string, they override the values sent in the body.

Callers

nothing calls this directly

Calls 5

readJSONIntoMethod · 0.95
ctxMethod · 0.95
addJSONMethod · 0.95
RevDiffMethod · 0.80
WriteMethod · 0.45

Tested by

no test coverage detected