diff --git a/configuration.go b/configuration.go index e89755e60..0796eb2cb 100644 --- a/configuration.go +++ b/configuration.go @@ -35,16 +35,16 @@ type Server struct { } type Route struct { - Rule string - Value string + Rule string + Value string } type Frontend struct { Backend string - Routes map[string]Route + Routes map[string]Route } type Configuration struct { - Backends map[string]Backend + Backends map[string]Backend Frontends map[string]Frontend } diff --git a/docker.go b/docker.go index 1265e7e37..422e5d9e6 100644 --- a/docker.go +++ b/docker.go @@ -2,23 +2,23 @@ package main import ( "bytes" + "errors" "github.com/BurntSushi/toml" "github.com/BurntSushi/ty/fun" + "github.com/cenkalti/backoff" "github.com/fsouza/go-dockerclient" "github.com/leekchan/gtf" - "github.com/cenkalti/backoff" "strconv" "strings" "text/template" - "errors" "time" ) type DockerProvider struct { - Watch bool - Endpoint string - Filename string - Domain string + Watch bool + Endpoint string + Filename string + Domain string } func NewDockerProvider() *DockerProvider { @@ -45,7 +45,7 @@ var DockerFuncMap = template.FuncMap{ return value } } - for key, _ := range container.NetworkSettings.Ports { + for key := range container.NetworkSettings.Ports { return key.Port() } return "" @@ -64,7 +64,7 @@ var DockerFuncMap = template.FuncMap{ "getHost": getHost, } -func (provider *DockerProvider) Provide(configurationChan chan <- *Configuration) { +func (provider *DockerProvider) Provide(configurationChan chan<- *Configuration) { if dockerClient, err := docker.NewClient(provider.Endpoint); err != nil { log.Fatalf("Failed to create a client for docker, error: %s", err) } else { @@ -83,9 +83,9 @@ func (provider *DockerProvider) Provide(configurationChan chan <- *Configuration event := <-dockerEvents if event == nil { return errors.New("Docker event nil") -// log.Fatalf("Docker connection error") + // log.Fatalf("Docker connection error") } - if (event.Status == "start" || event.Status == "die" ) { + if event.Status == "start" || event.Status == "die" { log.Debug("Docker event receveived %+v", event) configuration := provider.loadDockerConfig(dockerClient) if configuration != nil { diff --git a/middlewares/logger.go b/middlewares/logger.go index 1dc773f9a..650e671b8 100644 --- a/middlewares/logger.go +++ b/middlewares/logger.go @@ -4,10 +4,10 @@ Copyright package middlewares import ( + "github.com/gorilla/handlers" "log" "net/http" "os" - "github.com/gorilla/handlers" ) // Logger is a middleware handler that logs the request as it goes in and the response as it goes out. @@ -17,25 +17,25 @@ type Logger struct { // NewLogger returns a new Logger instance func NewLogger(file string) *Logger { - if (len(file) > 0 ) { - fi, err := os.OpenFile(file, os.O_RDWR | os.O_CREATE | os.O_APPEND, 0666) + if len(file) > 0 { + fi, err := os.OpenFile(file, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666) if err != nil { log.Fatal("Error opening file", err) } return &Logger{fi} - }else { + } else { return &Logger{nil} } } func (l *Logger) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc) { - if (l.file == nil) { + if l.file == nil { next(rw, r) - }else { + } else { handlers.CombinedLoggingHandler(l.file, next).ServeHTTP(rw, r) } } func (l *Logger) Close() { l.file.Close() -} \ No newline at end of file +} diff --git a/middlewares/routes.go b/middlewares/routes.go index 85889938a..1ab73db92 100644 --- a/middlewares/routes.go +++ b/middlewares/routes.go @@ -4,10 +4,10 @@ Copyright package middlewares import ( + "encoding/json" + "github.com/gorilla/mux" "log" "net/http" - "github.com/gorilla/mux" - "encoding/json" ) type Routes struct { @@ -19,8 +19,8 @@ func NewRoutes(router *mux.Router) *Routes { } func (router *Routes) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc) { - routeMatch :=mux.RouteMatch{} - if(router.router.Match(r, &routeMatch)){ + routeMatch := mux.RouteMatch{} + if router.router.Match(r, &routeMatch) { json, _ := json.Marshal(routeMatch.Handler) log.Println("Request match route ", json) } diff --git a/traefik.go b/traefik.go index 5fa0b7100..92f2e62a1 100644 --- a/traefik.go +++ b/traefik.go @@ -215,7 +215,7 @@ func LoadConfig(configuration *Configuration, gloablConfiguration *GlobalConfigu func Invoke(any interface{}, name string, args ...interface{}) []reflect.Value { inputs := make([]reflect.Value, len(args)) - for i, _ := range args { + for i := range args { inputs[i] = reflect.ValueOf(args[i]) } return reflect.ValueOf(any).MethodByName(name).Call(inputs)