Format some file using gofmt
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
This commit is contained in:
parent
1cc294872b
commit
fd835e1fcd
5 changed files with 26 additions and 26 deletions
|
@ -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
|
||||
}
|
||||
|
|
20
docker.go
20
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 {
|
||||
|
|
|
@ -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,21 +17,21 @@ 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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue