HUGE refactor. working towards web UI

This commit is contained in:
ari melody 2026-06-08 02:49:39 +01:00
parent dd54e8cc49
commit 1f94eecca9
Signed by: ari
GPG key ID: 60B5F0386E3DDB7E
29 changed files with 1669 additions and 162 deletions

View file

@ -16,16 +16,19 @@ type (
}
Config struct {
Host string `toml:"host" comment:"Address to host OAuth2 redirect flow"`
RedirectUri string `toml:"redirect_uri" comment:"URI to use in Google OAuth2 flow"`
Google GoogleConfig `toml:"google"`
Token *oauth2.Token `toml:"token" comment:"This section is filled in automatically on a successful authentication flow."`
Host string `toml:"host" comment:"Address to host OAuth2 redirect flow"`
Secure bool `toml:"bool" comment:"Whether or not host is secured with TLS (HTTPS)"`
Port int16 `toml:"port"`
VODDirectory string `toml:"vod_directory" comment:"Directory to be used for VOD management"`
Google GoogleConfig `toml:"google"`
Token *oauth2.Token `toml:"token" comment:"This section is filled in automatically on a successful authentication flow."`
}
)
var defaultConfig = Config{
Host: "localhost:8090",
RedirectUri: "http://localhost:8090",
Host: "localhost",
Secure: false,
Port: 8080,
Google: GoogleConfig{
ApiKey: "<your API key here>",
ClientID: "<your client ID here>",
@ -38,15 +41,12 @@ var CONFIG_FILENAME string = "config.toml"
func ReadConfig(filename string) (*Config, error) {
cfgBytes, err := os.ReadFile(filename)
if err != nil {
if os.IsNotExist(err) {
return nil, nil
}
return nil, fmt.Errorf("failed to open file: %v", err)
}
var config Config
err = toml.Unmarshal(cfgBytes, &config)
if err != nil { return &config, fmt.Errorf("failed to parse: %v", err) }
if err != nil { return nil, err }
return &config, nil
}