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

Method handleGetDesignDoc

rest/view_api.go:25–51  ·  view source on GitHub ↗

HTTP handler for GET _design/$ddoc

()

Source from the content-addressed store, hash-verified

23
24// HTTP handler for GET _design/$ddoc
25func (h *handler) handleGetDesignDoc() error {
26 ddocID := h.PathVar("ddoc")
27 var result interface{}
28 if ddocID == db.DesignDocSyncGateway() {
29 // we serve this content here so that CouchDB 1.2 has something to
30 // hash into the replication-id, to correspond to our filter.
31 filter := "ok"
32 defaultCollection, err := h.db.GetDefaultDatabaseCollection()
33 if err != nil {
34 return err
35 }
36 if defaultCollection.ChannelMapper != nil {
37 hash := sha1.New()
38 _, _ = io.WriteString(hash, defaultCollection.ChannelMapper.Function())
39 filter = fmt.Sprint(hash.Sum(nil))
40 }
41 result = db.Body{"filters": db.Body{"bychannel": filter}}
42 } else {
43 var getErr error
44 result, getErr = h.db.GetDesignDoc(ddocID)
45 if getErr != nil {
46 return getErr
47 }
48 }
49 h.writeJSON(result)
50 return nil
51}
52
53// HTTP handler for PUT _design/$ddoc
54func (h *handler) handlePutDesignDoc() error {

Callers

nothing calls this directly

Calls 5

PathVarMethod · 0.95
writeJSONMethod · 0.95
DesignDocSyncGatewayFunction · 0.92
GetDesignDocMethod · 0.80

Tested by

no test coverage detected