refactor: clean code

- remove dead code
- replace Fprintf by Fprint.
This commit is contained in:
Fernandez Ludovic 2017-04-14 10:45:03 +02:00
parent a8cbe7ef5e
commit f4579e5f12
2 changed files with 6 additions and 11 deletions

View file

@ -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")
// })
}
}

View file

@ -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")
}