Simplify printing

This commit is contained in:
Bryan Boreham committed 2015-04-10 14:46:31 +01:00
1 parent c13980af4b
commit d32f328c24
3 files changed
+6 -9

No files matched your search

+2 -3
View File
@@ -5,7 +5,6 @@ import (
"github.com/gorilla/mux" "github.com/gorilla/mux"
"github.com/miekg/dns" "github.com/miekg/dns"
. "github.com/weaveworks/weave/common" . "github.com/weaveworks/weave/common"
"io"
"log" "log"
"net" "net"
"net/http" "net/http"
@@ -22,8 +21,8 @@ func ListenHTTP(version string, server *DNSServer, domain string, db Zone, port
muxRouter := mux.NewRouter() muxRouter := mux.NewRouter()
muxRouter.Methods("GET").Path("/status").HandlerFunc(func(w http.ResponseWriter, r *http.Request) { muxRouter.Methods("GET").Path("/status").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
io.WriteString(w, fmt.Sprintln("weave DNS", version)) fmt.Fprintln(w, "weave DNS", version)
io.WriteString(w, server.Status()) fmt.Fprintln(w, server.Status())
}) })
muxRouter.Methods("PUT").Path("/name/{id:.+}/{ip:.+}").HandlerFunc(func(w http.ResponseWriter, r *http.Request) { muxRouter.Methods("PUT").Path("/name/{id:.+}/{ip:.+}").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+1 -2
View File
@@ -7,7 +7,6 @@ import (
"github.com/weaveworks/weave/common/updater" "github.com/weaveworks/weave/common/updater"
weavedns "github.com/weaveworks/weave/nameserver" weavedns "github.com/weaveworks/weave/nameserver"
weavenet "github.com/weaveworks/weave/net" weavenet "github.com/weaveworks/weave/net"
"io"
"net" "net"
"os" "os"
"os/signal" "os/signal"
@@ -49,7 +48,7 @@ func main() {
flag.Parse() flag.Parse()
if justVersion { if justVersion {
io.WriteString(os.Stdout, fmt.Sprintf("weave DNS %s\n", version)) fmt.Printf("weave DNS %s\n", version)
os.Exit(0) os.Exit(0)
} }
+3 -4
View File
@@ -9,7 +9,6 @@ import (
"github.com/gorilla/mux" "github.com/gorilla/mux"
weavenet "github.com/weaveworks/weave/net" weavenet "github.com/weaveworks/weave/net"
weave "github.com/weaveworks/weave/router" weave "github.com/weaveworks/weave/router"
"io"
"log" "log"
"net" "net"
"net/http" "net/http"
@@ -168,9 +167,9 @@ func handleHTTP(router *weave.Router, httpAddr string) {
muxRouter := mux.NewRouter() muxRouter := mux.NewRouter()
muxRouter.Methods("GET").Path("/status").HandlerFunc(func(w http.ResponseWriter, r *http.Request) { muxRouter.Methods("GET").Path("/status").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
io.WriteString(w, fmt.Sprintln("weave router", version)) fmt.Fprintln(w, "weave router", version)
io.WriteString(w, fmt.Sprintln("Encryption", encryption)) fmt.Fprintln(w, "Encryption", encryption)
io.WriteString(w, router.Status()) fmt.Fprintln(w, router.Status())
}) })
muxRouter.Methods("GET").Path("/status-json").HandlerFunc(func(w http.ResponseWriter, r *http.Request) { muxRouter.Methods("GET").Path("/status-json").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {