feature: Customizable external rest address

This commit is contained in:
jamesread 2022-04-05 11:06:41 +01:00
parent 63068dfdea
commit a725b377cc
3 changed files with 6 additions and 10 deletions

View File

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

View File

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

View File

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