From f4579e5f12c5ddd66709b350e928dfa7c9a3ad96 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Fri, 14 Apr 2017 10:45:03 +0200 Subject: [PATCH] refactor: clean code - remove dead code - replace Fprintf by Fprint. --- server/server.go | 5 ----- server/web.go | 12 ++++++------ 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/server/server.go b/server/server.go index 23d6400fa..6045cd35f 100644 --- a/server/server.go +++ b/server/server.go @@ -162,11 +162,6 @@ func (server *Server) Close() { func (server *Server) startLeadership() { if server.leadership != nil { server.leadership.Participate(server.routinesPool) - // server.leadership.AddGoCtx(func(ctx context.Context) { - // log.Debugf("Started test routine") - // <-ctx.Done() - // log.Debugf("Stopped test routine") - // }) } } diff --git a/server/web.go b/server/web.go index ac1d38fe0..b5f8ad41a 100644 --- a/server/web.go +++ b/server/web.go @@ -92,13 +92,13 @@ func (provider *WebProvider) Provide(configurationChan chan<- types.ConfigMessag systemRouter.Methods("PUT").Path(provider.Path + "api/providers/{provider}").HandlerFunc(func(response http.ResponseWriter, request *http.Request) { if provider.ReadOnly { response.WriteHeader(http.StatusForbidden) - fmt.Fprintf(response, "REST API is in read-only mode") + fmt.Fprint(response, "REST API is in read-only mode") return } vars := mux.Vars(request) if vars["provider"] != "web" { response.WriteHeader(http.StatusBadRequest) - fmt.Fprintf(response, "Only 'web' provider can be updated through the REST API") + fmt.Fprint(response, "Only 'web' provider can be updated through the REST API") return } @@ -174,7 +174,7 @@ func (provider *WebProvider) getHealthHandler(response http.ResponseWriter, requ } func (provider *WebProvider) getPingHandler(response http.ResponseWriter, request *http.Request) { - fmt.Fprintf(response, "OK") + fmt.Fprint(response, "OK") } func (provider *WebProvider) getConfigHandler(response http.ResponseWriter, request *http.Request) { @@ -319,14 +319,14 @@ func (provider *WebProvider) getRouteHandler(response http.ResponseWriter, reque func expvarHandler(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=utf-8") - fmt.Fprintf(w, "{\n") + fmt.Fprint(w, "{\n") first := true expvar.Do(func(kv expvar.KeyValue) { if !first { - fmt.Fprintf(w, ",\n") + fmt.Fprint(w, ",\n") } first = false fmt.Fprintf(w, "%q: %s", kv.Key, kv.Value) }) - fmt.Fprintf(w, "\n}\n") + fmt.Fprint(w, "\n}\n") }