Repository: syncthing/syncthing
File: lib/api/api.go (Go)

Code before:
		Status: svcutil.ExitSuccess,
	})
}

func (s *service) flushResponse(resp string, w http.ResponseWriter) {
	w.Write([]byte(resp + "\n"))
	f := w.(http.Flusher)
	f.Flush()
}

func (s *service) getSystemStatus(w http.ResponseWriter, r *http.Request) {
	var m runtime.MemStats
	runtime.ReadMemStats(&m)

	tilde, _ := fs.ExpandTilde("~")
	res := make(map[string]interface{})
	res["myID"] = s.id.String()
	res["goroutines"] = runtime.NumGoroutine()
	res["alloc"] = m.Alloc
	res["sys"] = m.Sys - m.HeapReleased
	res["tilde"] = tilde
	if s.cfg.Options().LocalAnnEnabled || s.cfg.Options().GlobalAnnEnabled {
		res["discoveryEnabled"] = true
		discoStatus := s.discoverer.FinderStatus()
		res["discoveryMethods"] = len(discoStatus) // DEPRECATED: Redundant, only for backwards compatibility, should be removed.
		res["discoveryErrors"] = discoStatus
	}

	res["connectionServiceStatus"] = s.connectionsService.ListenerStatus()
	res["lastDialStatus"] = s.connectionsService.ConnectionStatus()
	res["cpuPercent"] = 0 // deprecated from API
	res["pathSeparator"] = string(filepath.Separator)
	res["urVersionMax"] = ur.Version
	res["uptime"] = s.urService.UptimeS()
	res["startTime"] = ur.StartTime
	res["guiAddressOverridden"] = s.cfg.GUI().IsOverridden()
	res["guiAddressUsed"] = s.listenerAddr.String()

	sendJSON(w, res)
}

func (s *service) getSystemError(w http.ResponseWriter, r *http.Request) {
	sendJSON(w, map[string][]logger.Line{
		"errors": s.guiErrors.Since(time.Time{}),
	})
}

func (s *service) postSystemError(w http.ResponseWriter, r *http.Request) {
	bs, _ := ioutil.ReadAll(r.Body)
	r.Body.Close()
	l.Warnln(string(bs))

Review comment (suggestion):
I'd add a "discoveryStatus" key and mark "discoveryErrors" as deprecated too, as the errors bit is misleading (I assumed it was only discovery methods with errors at first).

Code after:
		Status: svcutil.ExitSuccess,
	})
}

func (s *service) flushResponse(resp string, w http.ResponseWriter) {
	w.Write([]byte(resp + "\n"))
	f := w.(http.Flusher)
	f.Flush()
}

func (s *service) getSystemStatus(w http.ResponseWriter, r *http.Request) {
	var m runtime.MemStats
	runtime.ReadMemStats(&m)

	tilde, _ := fs.ExpandTilde("~")
	res := make(map[string]interface{})
	res["myID"] = s.id.String()
	res["goroutines"] = runtime.NumGoroutine()
	res["alloc"] = m.Alloc
	res["sys"] = m.Sys - m.HeapReleased
	res["tilde"] = tilde
	if s.cfg.Options().LocalAnnEnabled || s.cfg.Options().GlobalAnnEnabled {
		res["discoveryEnabled"] = true
		discoStatus := s.discoverer.ChildErrors()
		res["discoveryStatus"] = discoveryStatusMap(discoStatus)
		res["discoveryMethods"] = len(discoStatus) // DEPRECATED: Redundant, only for backwards compatibility, should be removed.
		discoErrors := make(map[string]*string, len(discoStatus))
		for s, e := range discoStatus {
			if e != nil {
				discoErrors[s] = errorString(e)
			}
		}
		res["discoveryErrors"] = discoErrors // DEPRECATED: Redundant, only for backwards compatibility, should be removed.
	}

	res["connectionServiceStatus"] = s.connectionsService.ListenerStatus()
	res["lastDialStatus"] = s.connectionsService.ConnectionStatus()
	res["cpuPercent"] = 0 // deprecated from API
	res["pathSeparator"] = string(filepath.Separator)
	res["urVersionMax"] = ur.Version
	res["uptime"] = s.urService.UptimeS()
	res["startTime"] = ur.StartTime
	res["guiAddressOverridden"] = s.cfg.GUI().IsOverridden()
	res["guiAddressUsed"] = s.listenerAddr.String()

	sendJSON(w, res)
}

func (s *service) getSystemError(w http.ResponseWriter, r *http.Request) {
	sendJSON(w, map[string][]logger.Line{
		"errors": s.guiErrors.Since(time.Time{}),