Move installation of /install handlers into a separate optional function

This commit is contained in:
Eugene Bujak
2019-02-06 16:48:04 +03:00
parent 06a28a461d
commit 398312cd80
2 changed files with 11 additions and 5 deletions

7
app.go
View File

@@ -145,9 +145,14 @@ func run(args options) {
box := packr.NewBox("build/static")
// if not configured, redirect / to /install.html, otherwise redirect /install.html to /
http.Handle("/", postInstallHandler(optionalAuthHandler(http.FileServer(box))))
http.Handle("/install.html", preInstallHandler(http.FileServer(box)))
registerControlHandlers()
// add handlers for /install paths, we only need them when we're not configured yet
if config.firstRun {
http.Handle("/install.html", preInstallHandler(http.FileServer(box)))
registerInstallHandlers()
}
// this loop is used as an ability to change listening host and/or port
for {
address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort))