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

Provide a ui-web-path config #15

Merged
merged 3 commits into from Mar 13, 2016
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
2 changes: 2 additions & 0 deletions config/config.go
Expand Up @@ -10,12 +10,14 @@ func DefaultConfig() *Config {
return &Config{
APIHost: "",
UIBindAddr: "0.0.0.0:8025",
WebPath: "",
}
}

type Config struct {
APIHost string
UIBindAddr string
WebPath string
}

var cfg = DefaultConfig()
Expand Down
15 changes: 10 additions & 5 deletions web/web.go
Expand Up @@ -14,6 +14,7 @@ import (
)

var APIHost string
var WebPath string

type Web struct {
config *config.Config
Expand All @@ -26,11 +27,15 @@ func CreateWeb(cfg *config.Config, pat *pat.Router, asset func(string) ([]byte,
asset: asset,
}

pat.Path("/images/{file:.*}").Methods("GET").HandlerFunc(web.Static("assets/images/{{file}}"))
pat.Path("/css/{file:.*}").Methods("GET").HandlerFunc(web.Static("assets/css/{{file}}"))
pat.Path("/js/{file:.*}").Methods("GET").HandlerFunc(web.Static("assets/js/{{file}}"))
pat.Path("/fonts/{file:.*}").Methods("GET").HandlerFunc(web.Static("assets/fonts/{{file}}"))
pat.Path("/").Methods("GET").HandlerFunc(web.Index())
WebPath = cfg.WebPath

log.Printf("Serving under http://%s%s/", cfg.UIBindAddr, WebPath)

pat.Path(WebPath + "/images/{file:.*}").Methods("GET").HandlerFunc(web.Static("assets/images/{{file}}"))
pat.Path(WebPath + "/css/{file:.*}").Methods("GET").HandlerFunc(web.Static("assets/css/{{file}}"))
pat.Path(WebPath + "/js/{file:.*}").Methods("GET").HandlerFunc(web.Static("assets/js/{{file}}"))
pat.Path(WebPath + "/fonts/{file:.*}").Methods("GET").HandlerFunc(web.Static("assets/fonts/{{file}}"))
pat.StrictSlash(true).Path(WebPath + "/").Methods("GET").HandlerFunc(web.Index())

return web
}
Expand Down