From 84c6f147ad4e8bf3832b0364ea03b0f56c674499 Mon Sep 17 00:00:00 2001 From: Audrius Butkevicius Date: Thu, 21 Aug 2014 23:46:34 +0100 Subject: [PATCH] Add /rest/stats/node endpoint --- cmd/syncthing/gui.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cmd/syncthing/gui.go b/cmd/syncthing/gui.go index 3aa40e02..6b145c87 100644 --- a/cmd/syncthing/gui.go +++ b/cmd/syncthing/gui.go @@ -111,6 +111,7 @@ func startGUI(cfg config.GUIConfiguration, assetDir string, m *model.Model) erro getRestMux.HandleFunc("/rest/system", restGetSystem) getRestMux.HandleFunc("/rest/upgrade", restGetUpgrade) getRestMux.HandleFunc("/rest/version", restGetVersion) + getRestMux.HandleFunc("/rest/stats/node", withModel(m, restGetNodeStats)) // Debug endpoints, not for general use getRestMux.HandleFunc("/rest/debug/peerCompletion", withModel(m, restGetPeerCompletion)) @@ -265,6 +266,12 @@ func restGetConnections(m *model.Model, w http.ResponseWriter, r *http.Request) json.NewEncoder(w).Encode(res) } +func restGetNodeStats(m *model.Model, w http.ResponseWriter, r *http.Request) { + var res = m.NodeStatistics() + w.Header().Set("Content-Type", "application/json; charset=utf-8") + json.NewEncoder(w).Encode(res) +} + func restGetConfig(w http.ResponseWriter, r *http.Request) { encCfg := cfg if encCfg.GUI.Password != "" {