output json status based on 'Accept' header

...instead if having a separate URL.

Closes #1063.
This commit is contained in:
Matthias Radestock committed 2015-07-05 19:19:02 +01:00
1 parent 5559f1df2e
commit 098fc81825
1 file changed
+5 -5
+5 -5
View File
@@ -259,6 +259,11 @@ func handleHTTP(router *weave.Router, httpAddr string, allocator *ipam.Allocator
allocator.HandleHTTP(muxRouter, defaultSubnet, docker)
}
muxRouter.Methods("GET").Path("/status").Headers("Accept", "application/json").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
json, _ := router.StatusJSON(version)
w.Write(json)
})
muxRouter.Methods("GET").Path("/status").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "weave router", version)
fmt.Fprintln(w, router.Status())
@@ -268,11 +273,6 @@ func handleHTTP(router *weave.Router, httpAddr string, allocator *ipam.Allocator
}
})
muxRouter.Methods("GET").Path("/status-json").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
json, _ := router.StatusJSON(version)
w.Write(json)
})
muxRouter.Methods("POST").Path("/connect").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if err := r.ParseForm(); err != nil {
http.Error(w, fmt.Sprint("unable to parse form: ", err), http.StatusBadRequest)