From 7d4675f54218e4616bf4844f8b8145667ed33df5 Mon Sep 17 00:00:00 2001 From: emile Date: Fri, 11 Sep 2015 18:55:38 +0200 Subject: [PATCH] refactoring --- ROADMAP.md | 2 +- traefik.go | 8 +++++++- traefik.toml | 4 ++-- web.go | 11 ++--------- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/ROADMAP.md b/ROADMAP.md index 9c549748d..119809e4e 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -2,7 +2,6 @@ * Default configuration values * Retry with streams -* Static files * Licence * Add traefik.indlude all/enabled policy * SSL backends support @@ -24,3 +23,4 @@ * ~~Filter no exposed port apps~~ * ~~Logs~~ * ~~SSL frontend support~~ +* ~~Static files~~ diff --git a/traefik.go b/traefik.go index 660a5961d..243725f2f 100644 --- a/traefik.go +++ b/traefik.go @@ -15,10 +15,16 @@ import ( "github.com/op/go-logging" "github.com/BurntSushi/toml" "github.com/gorilla/handlers" + "github.com/unrolled/render" ) var currentConfiguration = new(Configuration) var log = logging.MustGetLogger("traefik") +var templatesRenderer = render.New(render.Options{ + Directory: "templates", + Asset: Asset, + AssetNames: AssetNames, +}) func main() { var srv *graceful.Server @@ -145,7 +151,7 @@ func main() { } func notFoundHandler(w http.ResponseWriter, r *http.Request) { - renderer.HTML(w, http.StatusNotFound, "notFound", nil) + templatesRenderer.HTML(w, http.StatusNotFound, "notFound", nil) } func LoadDefaultConfig(gloablConfiguration *GlobalConfiguration) *mux.Router { diff --git a/traefik.toml b/traefik.toml index fa068e060..b72fcc428 100644 --- a/traefik.toml +++ b/traefik.toml @@ -1,8 +1,8 @@ port = ":8001" graceTimeOut = 10 -traefikLogsFile = "log/traefik.log" +# traefikLogsFile = "log/traefik.log" traefikLogsStdout = true -accessLogsFile = "log/access.log" +# accessLogsFile = "log/access.log" logLevel = "DEBUG" [docker] diff --git a/web.go b/web.go index 8162c62fa..da72c595c 100644 --- a/web.go +++ b/web.go @@ -3,19 +3,12 @@ package main import ( "github.com/gorilla/mux" "net/http" - "github.com/unrolled/render" "fmt" "io/ioutil" "encoding/json" "github.com/elazarl/go-bindata-assetfs" ) -var renderer = render.New(render.Options{ - Directory: "templates", - Asset: Asset, - AssetNames: AssetNames, -}) - type WebProvider struct { Address string } @@ -47,9 +40,9 @@ func (provider *WebProvider) Provide(configurationChan chan <- *Configuration) { } func GetConfigHandler(rw http.ResponseWriter, r *http.Request) { - renderer.JSON(rw, http.StatusOK, currentConfiguration) + templatesRenderer.JSON(rw, http.StatusOK, currentConfiguration) } func GetHtmlConfigHandler(response http.ResponseWriter, request *http.Request) { - renderer.HTML(response, http.StatusOK, "configuration", Page{Configuration:*currentConfiguration}) + templatesRenderer.HTML(response, http.StatusOK, "configuration", Page{Configuration:*currentConfiguration}) }