change how config is loaded
This commit is contained in:
@@ -1,20 +0,0 @@
|
||||
package conf
|
||||
|
||||
type PixelWebConfig struct {
|
||||
APIURLExternal string `toml:"api_url_external"`
|
||||
APIURLInternal string `toml:"api_url_internal"`
|
||||
SessionCookieDomain string `toml:"session_cookie_domain"`
|
||||
ResourceDir string `toml:"resource_dir"`
|
||||
DebugMode bool `toml:"debug_mode"`
|
||||
MaintenanceMode bool `toml:"maintenance_mode"`
|
||||
}
|
||||
|
||||
const DefaultConfig = `# Pixeldrain Web UI server configuration
|
||||
|
||||
api_url_external = "/api" # Used in the web browser
|
||||
api_url_internal = "http://127.0.0.1:8080" # Used for internal API requests to the pixeldrain server, not visible to users
|
||||
session_cookie_domain = ".pixeldrain.com"
|
||||
resource_dir = "res"
|
||||
debug_mode = false
|
||||
maintenance_mode = false
|
||||
`
|
37
init/init.go
37
init/init.go
@@ -3,20 +3,40 @@ package init
|
||||
import (
|
||||
"os"
|
||||
|
||||
"fornaxian.com/pixeldrain-web/init/conf"
|
||||
"fornaxian.com/pixeldrain-web/webcontroller"
|
||||
"github.com/Fornaxian/config"
|
||||
"github.com/Fornaxian/log"
|
||||
"github.com/julienschmidt/httprouter"
|
||||
)
|
||||
|
||||
// PixelWebConfig contains the Pixeldrain Web UI configuration
|
||||
type PixelWebConfig struct {
|
||||
APIURLExternal string `toml:"api_url_external"`
|
||||
APIURLInternal string `toml:"api_url_internal"`
|
||||
SessionCookieDomain string `toml:"session_cookie_domain"`
|
||||
ResourceDir string `toml:"resource_dir"`
|
||||
DebugMode bool `toml:"debug_mode"`
|
||||
MaintenanceMode bool `toml:"maintenance_mode"`
|
||||
}
|
||||
|
||||
// DefaultConfig is the default configuration for Pixeldrain Web
|
||||
const DefaultConfig = `# Pixeldrain Web UI server configuration
|
||||
|
||||
api_url_external = "/api" # Used in the web browser
|
||||
api_url_internal = "http://127.0.0.1:8080" # Used for internal API requests to the pixeldrain server, not visible to users
|
||||
session_cookie_domain = ".pixeldrain.com"
|
||||
resource_dir = "res"
|
||||
debug_mode = false
|
||||
maintenance_mode = false
|
||||
`
|
||||
|
||||
// Init initializes the Pixeldrain Web UI controllers
|
||||
func Init(r *httprouter.Router, prefix string, setLogLevel bool) {
|
||||
log.Info("Starting web UI server (PID %v)", os.Getpid())
|
||||
|
||||
var webconf = &conf.PixelWebConfig{}
|
||||
var webconf = &PixelWebConfig{}
|
||||
var _, err = config.New(
|
||||
conf.DefaultConfig,
|
||||
DefaultConfig,
|
||||
"",
|
||||
"pdwebconf.toml",
|
||||
webconf,
|
||||
@@ -31,5 +51,14 @@ func Init(r *httprouter.Router, prefix string, setLogLevel bool) {
|
||||
log.SetLogLevel(log.LevelInfo)
|
||||
}
|
||||
|
||||
webcontroller.New(r, prefix, webconf)
|
||||
webcontroller.New(
|
||||
r,
|
||||
prefix,
|
||||
webconf.ResourceDir,
|
||||
webconf.APIURLInternal,
|
||||
webconf.APIURLExternal,
|
||||
webconf.SessionCookieDomain,
|
||||
webconf.MaintenanceMode,
|
||||
webconf.DebugMode,
|
||||
)
|
||||
}
|
||||
|
Reference in New Issue
Block a user