Просмотр исходного кода

feature: Customizable external rest address

jamesread 4 лет назад
Родитель
Сommit
a725b377cc

+ 1 - 0
internal/config/config.go

@@ -87,6 +87,7 @@ func DefaultConfig() *Config {
 	config.ListenAddressRestActions = "localhost:1338"
 	config.ListenAddressGrpcActions = "localhost:1339"
 	config.ListenAddressWebUI = "localhost:1340"
+	config.ExternalRestAddress = ""
 	config.LogLevel = "INFO"
 	config.CheckForUpdates = true
 	config.DefaultPermissions.Exec = true

+ 3 - 2
internal/httpservers/httpServer.go

@@ -8,9 +8,10 @@ import (
 // for both of them.
 func StartServers(cfg *config.Config) {
 	go startWebUIServer(cfg)
-	go startRestAPIServer(cfg)
 
 	if cfg.UseSingleHTTPFrontend {
-		StartSingleHTTPFrontend(cfg)
+		go StartSingleHTTPFrontend(cfg)
 	}
+
+	startRestAPIServer(cfg)
 }

+ 2 - 8
internal/httpservers/webuiServer.go

@@ -44,16 +44,10 @@ func findWebuiDir() string {
 }
 
 func generateWebUISettings(w http.ResponseWriter, r *http.Request) {
-	restAddress := ""
-
-	if !cfg.UseSingleHTTPFrontend {
-		restAddress = cfg.ExternalRestAddress
-	}
-
 	jsonRet, _ := json.Marshal(webUISettings{
-		Rest:             restAddress + "/api/",
+		Rest:             cfg.ExternalRestAddress + "/api/",
 		ThemeName:        cfg.ThemeName,
-    ShowFooter:       cfg.ShowFooter,
+		ShowFooter:       cfg.ShowFooter,
 		ShowNavigation:   cfg.ShowNavigation,
 		ShowNewVersions:  cfg.ShowNewVersions,
 		AvailableVersion: updatecheck.AvailableVersion,