Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated assets file are only mandatory in main #3386

Merged
merged 1 commit into from
May 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 10 additions & 3 deletions api/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,22 @@ import (
"net/http"

"github.com/containous/mux"
"github.com/containous/traefik/autogen/genstatic"
"github.com/containous/traefik/log"
"github.com/elazarl/go-bindata-assetfs"
)

// DashboardHandler expose dashboard routes
type DashboardHandler struct{}
type DashboardHandler struct {
Assets *assetfs.AssetFS
}

// AddRoutes add dashboard routes on a router
func (g DashboardHandler) AddRoutes(router *mux.Router) {
if g.Assets == nil {
log.Error("No assets for dashboard")
return
}

// Expose dashboard
router.Methods(http.MethodGet).
Path("/").
Expand All @@ -28,5 +35,5 @@ func (g DashboardHandler) AddRoutes(router *mux.Router) {

router.Methods(http.MethodGet).
PathPrefix("/dashboard/").
Handler(http.StripPrefix("/dashboard/", http.FileServer(&assetfs.AssetFS{Asset: genstatic.Asset, AssetInfo: genstatic.AssetInfo, AssetDir: genstatic.AssetDir, Prefix: "static"})))
Handler(http.StripPrefix("/dashboard/", http.FileServer(g.Assets)))
}
4 changes: 3 additions & 1 deletion api/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/containous/traefik/safe"
"github.com/containous/traefik/types"
"github.com/containous/traefik/version"
"github.com/elazarl/go-bindata-assetfs"
thoas_stats "github.com/thoas/stats"
"github.com/unrolled/render"
)
Expand All @@ -22,6 +23,7 @@ type Handler struct {
Statistics *types.Statistics `description:"Enable more detailed statistics" export:"true"`
Stats *thoas_stats.Stats `json:"-"`
StatsRecorder *middlewares.StatsRecorder `json:"-"`
DashboardAssets *assetfs.AssetFS
}

var (
Expand Down Expand Up @@ -54,7 +56,7 @@ func (p Handler) AddRoutes(router *mux.Router) {
version.Handler{}.AddRoutes(router)

if p.Dashboard {
DashboardHandler{}.AddRoutes(router)
DashboardHandler{Assets: p.DashboardAssets}.AddRoutes(router)
}
}

Expand Down
6 changes: 6 additions & 0 deletions cmd/traefik/traefik.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/cenk/backoff"
"github.com/containous/flaeg"
"github.com/containous/staert"
"github.com/containous/traefik/autogen/genstatic"
"github.com/containous/traefik/cmd"
"github.com/containous/traefik/cmd/bug"
"github.com/containous/traefik/cmd/healthcheck"
Expand All @@ -33,6 +34,7 @@ import (
"github.com/containous/traefik/types"
"github.com/containous/traefik/version"
"github.com/coreos/go-systemd/daemon"
"github.com/elazarl/go-bindata-assetfs"
"github.com/ogier/pflag"
"github.com/sirupsen/logrus"
"github.com/vulcand/oxy/roundrobin"
Expand Down Expand Up @@ -163,6 +165,10 @@ func runCmd(globalConfiguration *configuration.GlobalConfiguration, configFile s
globalConfiguration.SetEffectiveConfiguration(configFile)
globalConfiguration.ValidateConfiguration()

if globalConfiguration.API != nil && globalConfiguration.API.Dashboard {
globalConfiguration.API.DashboardAssets = &assetfs.AssetFS{Asset: genstatic.Asset, AssetInfo: genstatic.AssetInfo, AssetDir: genstatic.AssetDir, Prefix: "static"}
}

jsonConf, _ := json.Marshal(globalConfiguration)
log.Infof("Traefik version %s built on %s", version.Version, version.BuildDate)

Expand Down