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

Method addJSON

rest/handler.go:1618–1633  ·  view source on GitHub ↗
(value interface{})

Source from the content-addressed store, hash-verified

1616}
1617
1618func (h *handler) addJSON(value interface{}) error {
1619 encoder := base.JSONEncoderCanonical(h.response)
1620 err := encoder.Encode(value)
1621 if err != nil {
1622 brokenPipeError := strings.Contains(err.Error(), "write: broken pipe")
1623 connectionResetError := strings.Contains(err.Error(), "write: connection reset")
1624 if brokenPipeError || connectionResetError {
1625 base.DebugfCtx(h.ctx(), base.KeyCRUD, "Couldn't serialize document body, HTTP client closed connection")
1626 return err
1627 } else {
1628 base.WarnfCtx(h.ctx(), "Couldn't serialize JSON for %s", err)
1629 h.writeStatus(http.StatusInternalServerError, "Couldn't serialize document body")
1630 }
1631 }
1632 return nil
1633}
1634
1635func (h *handler) writeMultipart(subtype string, callback func(*multipart.Writer) error) error {
1636 if !h.requestAccepts("multipart/") {

Callers 4

handleRevsDiffMethod · 0.95
handleGetDocMethod · 0.95
writeQueryRowsMethod · 0.95
handleAllDocsMethod · 0.95

Calls 8

ctxMethod · 0.95
writeStatusMethod · 0.95
JSONEncoderCanonicalFunction · 0.92
DebugfCtxFunction · 0.92
WarnfCtxFunction · 0.92
EncodeMethod · 0.65
ContainsMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected