MCPcopy Index your code
hub / github.com/syncthing/syncthing / sendJSON

Function sendJSON

lib/api/api.go:205–217  ·  view source on GitHub ↗
(w http.ResponseWriter, jsonObject interface{})

Source from the content-addressed store, hash-verified

203}
204
205func sendJSON(w http.ResponseWriter, jsonObject interface{}) {
206 w.Header().Set("Content-Type", "application/json")
207 // Marshalling might fail, in which case we should return a 500 with the
208 // actual error.
209 bs, err := json.MarshalIndent(jsonObject, "", " ")
210 if err != nil {
211 // This Marshal() can't fail though.
212 bs, _ = json.Marshal(map[string]string{"error": err.Error()})
213 http.Error(w, string(bs), http.StatusInternalServerError)
214 return
215 }
216 fmt.Fprintf(w, "%s\n", bs)
217}
218
219func (s *service) Serve(ctx context.Context) error {
220 listener, err := s.getListener(s.cfg.GUI())

Callers 15

getPendingDevicesMethod · 0.85
getPendingFoldersMethod · 0.85
restPingMethod · 0.85
getSystemPathsMethod · 0.85
getSystemVersionMethod · 0.85
getSystemDebugMethod · 0.85
getDBBrowseMethod · 0.85
getDBCompletionMethod · 0.85
getDBStatusMethod · 0.85
getDBNeedMethod · 0.85
getDBRemoteNeedMethod · 0.85
getDBLocalChangedMethod · 0.85

Calls 4

MarshalMethod · 0.80
ErrorMethod · 0.65
SetMethod · 0.45
HeaderMethod · 0.45

Tested by

no test coverage detected