(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
| 70 | } |
| 71 | |
| 72 | func (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 | |
| 100 | func (api *API) ServeV1WriteNQuad(w http.ResponseWriter, r *http.Request, params httprouter.Params) { |
| 101 | if api.config.ReadOnly { |
nothing calls this directly
no test coverage detected