|
@ -15,15 +15,15 @@ type FileSystemType int |
|
|
type Settings struct { |
|
|
type Settings struct { |
|
|
Endpoint string |
|
|
Endpoint string |
|
|
Token string |
|
|
Token string |
|
|
FileSystem FileSystemSettings |
|
|
|
|
|
|
|
|
StorageProvider StorageSettings |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
type FileSystemSettings struct { |
|
|
|
|
|
|
|
|
type StorageSettings struct { |
|
|
Type FileSystemType |
|
|
Type FileSystemType |
|
|
BasePath string |
|
|
BasePath string |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func ParseSettings(data []byte) Settings { |
|
|
|
|
|
|
|
|
func parseSettings(data []byte) Settings { |
|
|
settings := Settings{} |
|
|
settings := Settings{} |
|
|
|
|
|
|
|
|
json.Unmarshal(data, &settings) |
|
|
json.Unmarshal(data, &settings) |
|
@ -39,14 +39,14 @@ func LoadSettings() Settings { |
|
|
data, err := os.ReadFile(path) |
|
|
data, err := os.ReadFile(path) |
|
|
|
|
|
|
|
|
if err == nil { |
|
|
if err == nil { |
|
|
return ParseSettings(data) |
|
|
|
|
|
|
|
|
return parseSettings(data) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// If file does not exist, create default settings
|
|
|
// If file does not exist, create default settings
|
|
|
defaultSettings := Settings{ |
|
|
defaultSettings := Settings{ |
|
|
Endpoint: "127.0.0.1:8000", |
|
|
Endpoint: "127.0.0.1:8000", |
|
|
Token: "changeme", |
|
|
Token: "changeme", |
|
|
FileSystem: FileSystemSettings{ |
|
|
|
|
|
|
|
|
StorageProvider: StorageSettings{ |
|
|
Type: Local, |
|
|
Type: Local, |
|
|
BasePath: "assets", |
|
|
BasePath: "assets", |
|
|
}, |
|
|
}, |
|
|