Obtain status info in JSON format

This commit is contained in:
Bryan Boreham committed 2015-01-21 21:03:16 +00:00
1 parent 6efa794ab4
commit c7af02776f
2 files changed
+83

No files matched your search

+5
View File
@@ -145,6 +145,11 @@ func handleHttp(router *weave.Router) {
io.WriteString(w, fmt.Sprintln("Encryption", encryption))
io.WriteString(w, router.Status())
})
http.HandleFunc("/status-json", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Access-Control-Allow-Origin", "*")
json, _ := router.MarshalJSON()
w.Write(json)
})
http.HandleFunc("/connect", func(w http.ResponseWriter, r *http.Request) {
peer := r.FormValue("peer")
if addr, err := net.ResolveTCPAddr("tcp4", weave.NormalisePeerAddr(peer)); err == nil {