MCPcopy
hub / github.com/cayleygraph/cayley / ServeV1Write

Method ServeV1Write

internal/http/write.go:72–98  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request, _ httprouter.Params)

Source from the content-addressed store, hash-verified

70}
71
72func (api *API) ServeV1Write(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
73 if api.config.ReadOnly {
74 jsonResponse(w, 400, "Database is read-only.")
75 return
76 }
77 // TODO: streaming reader
78 bodyBytes, err := readLimit(r.Body)
79 if err != nil {
80 jsonResponse(w, 400, err)
81 return
82 }
83 quads, err := ParseJSONToQuadList(bodyBytes)
84 if err != nil {
85 jsonResponse(w, 400, err)
86 return
87 }
88 h, err := api.GetHandleForRequest(r)
89 if err != nil {
90 jsonResponse(w, 400, err)
91 return
92 }
93 if err = h.QuadWriter.AddQuadSet(quads); err != nil {
94 jsonResponse(w, 400, err)
95 return
96 }
97 fmt.Fprintf(w, "{\"result\": \"Successfully wrote %d quads.\"}", len(quads))
98}
99
100func (api *API) ServeV1WriteNQuad(w http.ResponseWriter, r *http.Request, params httprouter.Params) {
101 if api.config.ReadOnly {

Callers

nothing calls this directly

Calls 5

GetHandleForRequestMethod · 0.95
ParseJSONToQuadListFunction · 0.85
jsonResponseFunction · 0.70
readLimitFunction · 0.70
AddQuadSetMethod · 0.65

Tested by

no test coverage detected