refactoring
This commit is contained in:
parent
4a83136970
commit
7d4675f542
4 changed files with 12 additions and 13 deletions
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
* Default configuration values
|
* Default configuration values
|
||||||
* Retry with streams
|
* Retry with streams
|
||||||
* Static files
|
|
||||||
* Licence
|
* Licence
|
||||||
* Add traefik.indlude all/enabled policy
|
* Add traefik.indlude all/enabled policy
|
||||||
* SSL backends support
|
* SSL backends support
|
||||||
|
@ -24,3 +23,4 @@
|
||||||
* ~~Filter no exposed port apps~~
|
* ~~Filter no exposed port apps~~
|
||||||
* ~~Logs~~
|
* ~~Logs~~
|
||||||
* ~~SSL frontend support~~
|
* ~~SSL frontend support~~
|
||||||
|
* ~~Static files~~
|
||||||
|
|
|
@ -15,10 +15,16 @@ import (
|
||||||
"github.com/op/go-logging"
|
"github.com/op/go-logging"
|
||||||
"github.com/BurntSushi/toml"
|
"github.com/BurntSushi/toml"
|
||||||
"github.com/gorilla/handlers"
|
"github.com/gorilla/handlers"
|
||||||
|
"github.com/unrolled/render"
|
||||||
)
|
)
|
||||||
|
|
||||||
var currentConfiguration = new(Configuration)
|
var currentConfiguration = new(Configuration)
|
||||||
var log = logging.MustGetLogger("traefik")
|
var log = logging.MustGetLogger("traefik")
|
||||||
|
var templatesRenderer = render.New(render.Options{
|
||||||
|
Directory: "templates",
|
||||||
|
Asset: Asset,
|
||||||
|
AssetNames: AssetNames,
|
||||||
|
})
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
var srv *graceful.Server
|
var srv *graceful.Server
|
||||||
|
@ -145,7 +151,7 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func notFoundHandler(w http.ResponseWriter, r *http.Request) {
|
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 {
|
func LoadDefaultConfig(gloablConfiguration *GlobalConfiguration) *mux.Router {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
port = ":8001"
|
port = ":8001"
|
||||||
graceTimeOut = 10
|
graceTimeOut = 10
|
||||||
traefikLogsFile = "log/traefik.log"
|
# traefikLogsFile = "log/traefik.log"
|
||||||
traefikLogsStdout = true
|
traefikLogsStdout = true
|
||||||
accessLogsFile = "log/access.log"
|
# accessLogsFile = "log/access.log"
|
||||||
logLevel = "DEBUG"
|
logLevel = "DEBUG"
|
||||||
|
|
||||||
[docker]
|
[docker]
|
||||||
|
|
11
web.go
11
web.go
|
@ -3,19 +3,12 @@ package main
|
||||||
import (
|
import (
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"net/http"
|
"net/http"
|
||||||
"github.com/unrolled/render"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/elazarl/go-bindata-assetfs"
|
"github.com/elazarl/go-bindata-assetfs"
|
||||||
)
|
)
|
||||||
|
|
||||||
var renderer = render.New(render.Options{
|
|
||||||
Directory: "templates",
|
|
||||||
Asset: Asset,
|
|
||||||
AssetNames: AssetNames,
|
|
||||||
})
|
|
||||||
|
|
||||||
type WebProvider struct {
|
type WebProvider struct {
|
||||||
Address string
|
Address string
|
||||||
}
|
}
|
||||||
|
@ -47,9 +40,9 @@ func (provider *WebProvider) Provide(configurationChan chan <- *Configuration) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetConfigHandler(rw http.ResponseWriter, r *http.Request) {
|
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) {
|
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})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue