Add version and encryption status into the JSON output

This commit is contained in:
Bryan Boreham committed 2015-02-06 17:35:39 +00:00
1 parent e600816d5f
commit 410972906b
2 files changed
+5 -3

No files matched your search

+4 -2
View File
@@ -6,13 +6,15 @@ import (
"time"
)
func (router *Router) MarshalJSON() ([]byte, error) {
func (router *Router) GenerateStatusJSON(version, encryption string) ([]byte, error) {
return json.Marshal(struct {
Version string
Encryption string
Name, Interface string
Macs *MacCache
Peers *Peers
Routes *Routes
}{router.Ourself.Name.String(), fmt.Sprintf("%v", router.Iface), router.Macs, router.Peers, router.Routes})
}{version, encryption, router.Ourself.Name.String(), fmt.Sprintf("%v", router.Iface), router.Macs, router.Peers, router.Routes})
// leaving out ConectionMaker due to async complexities
}
+1 -1
View File
@@ -146,7 +146,7 @@ func handleHttp(router *weave.Router) {
io.WriteString(w, router.Status())
})
http.HandleFunc("/status-json", func(w http.ResponseWriter, r *http.Request) {
json, _ := router.MarshalJSON()
json, _ := router.GenerateStatusJSON(version, encryption)
w.Write(json)
})
http.HandleFunc("/connect", func(w http.ResponseWriter, r *http.Request) {