diff --git a/app.go b/app.go index f72a9d08..e72a7f2c 100644 --- a/app.go +++ b/app.go @@ -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)) diff --git a/control.go b/control.go index 912f3425..a310ab58 100644 --- a/control.go +++ b/control.go @@ -801,6 +801,11 @@ func handleInstallConfigure(w http.ResponseWriter, r *http.Request) { }() } +func registerInstallHandlers() { + http.HandleFunc("/control/install/get_addresses", preInstall(ensureGET(handleInstallGetAddresses))) + http.HandleFunc("/control/install/configure", preInstall(ensurePOST(handleInstallConfigure))) +} + func registerControlHandlers() { http.HandleFunc("/control/status", postInstall(optionalAuth(ensureGET(handleStatus)))) http.HandleFunc("/control/enable_protection", postInstall(optionalAuth(ensurePOST(handleProtectionEnable)))) @@ -839,8 +844,4 @@ func registerControlHandlers() { http.HandleFunc("/control/dhcp/interfaces", postInstall(optionalAuth(ensureGET(handleDHCPInterfaces)))) http.HandleFunc("/control/dhcp/set_config", postInstall(optionalAuth(ensurePOST(handleDHCPSetConfig)))) http.HandleFunc("/control/dhcp/find_active_dhcp", postInstall(optionalAuth(ensurePOST(handleDHCPFindActiveServer)))) - - // TODO: move to registerInstallHandlers() - http.HandleFunc("/control/install/get_addresses", preInstall(ensureGET(handleInstallGetAddresses))) - http.HandleFunc("/control/install/configure", preInstall(ensurePOST(handleInstallConfigure))) }