dashboard: handle correctly baseurl option
On the first public.html GET, load the index.html file, as Go Template.
This commit is contained in:
parent
ca891cd9b2
commit
ded583008a
3 changed files with 46 additions and 22 deletions
|
|
@ -66,7 +66,7 @@ func StripPrefix(prefix string, h http.Handler) http.Handler {
|
|||
func main() {
|
||||
// Read parameters from command line
|
||||
var bind = flag.String("bind", "127.0.0.1:8082", "Bind port/socket")
|
||||
var baseURL = flag.String("baseurl", "/", "URL prepended to each URL")
|
||||
flag.StringVar(&BaseURL, "baseurl", BaseURL, "URL prepended to each URL")
|
||||
flag.StringVar(&StaticDir, "static", "./htdocs-dashboard/", "Directory containing static files")
|
||||
flag.StringVar(&fic.FilesDir, "files", fic.FilesDir, "Base directory where found challenges files, local part")
|
||||
flag.StringVar(&DashboardDir, "dashbord", "./DASHBOARD", "Base directory where save public JSON files")
|
||||
|
|
@ -90,12 +90,10 @@ func main() {
|
|||
if settings.SettingsDir, err = filepath.Abs(settings.SettingsDir); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if *baseURL != "/" {
|
||||
tmp := path.Clean(*baseURL)
|
||||
baseURL = &tmp
|
||||
if BaseURL != "/" {
|
||||
BaseURL = path.Clean(BaseURL)
|
||||
} else {
|
||||
tmp := ""
|
||||
baseURL = &tmp
|
||||
BaseURL = ""
|
||||
}
|
||||
if fwdr != nil && len(*fwdr) > 0 {
|
||||
forwarder = fwdr
|
||||
|
|
@ -107,7 +105,7 @@ func main() {
|
|||
|
||||
srv := &http.Server{
|
||||
Addr: *bind,
|
||||
Handler: StripPrefix(*baseURL, api.Router()),
|
||||
Handler: StripPrefix(BaseURL, api.Router()),
|
||||
}
|
||||
|
||||
// Serve content
|
||||
|
|
|
|||
Reference in a new issue