Browse Source
Add tags for json serialization to settings structs
feature/add-settings
Fabian Vowie
3 years ago
No known key found for this signature in database
GPG Key ID: C27317C33B27C410
2 changed files with
7 additions and
7 deletions
-
settings/settings.go
-
settings/settings_test.go
|
@ -15,14 +15,14 @@ const ( |
|
|
type FileSystemType int |
|
|
type FileSystemType int |
|
|
|
|
|
|
|
|
type Settings struct { |
|
|
type Settings struct { |
|
|
Endpoint string |
|
|
|
|
|
Token string |
|
|
|
|
|
StorageProvider StorageSettings |
|
|
|
|
|
|
|
|
Endpoint string `json:"endpoint"` |
|
|
|
|
|
Token string `json:"token"` |
|
|
|
|
|
StorageProvider StorageSettings `json:"storage_provider"` |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
type StorageSettings struct { |
|
|
type StorageSettings struct { |
|
|
Type FileSystemType |
|
|
|
|
|
BasePath string |
|
|
|
|
|
|
|
|
Type FileSystemType `json:"type"` |
|
|
|
|
|
BasePath string `json:"base_path"` |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func parseSettings(data []byte) Settings { |
|
|
func parseSettings(data []byte) Settings { |
|
|
|
@ -13,9 +13,9 @@ func TestSettingsParsing(t *testing.T) { |
|
|
const file string = `{ |
|
|
const file string = `{ |
|
|
"endpoint": "0.0.0.0:8000", |
|
|
"endpoint": "0.0.0.0:8000", |
|
|
"token": "foobar", |
|
|
"token": "foobar", |
|
|
"storageProvider": { |
|
|
|
|
|
|
|
|
"storage_provider": { |
|
|
"type": 0, |
|
|
"type": 0, |
|
|
"basePath": "assets" |
|
|
|
|
|
|
|
|
"base_path": "assets" |
|
|
} |
|
|
} |
|
|
}` |
|
|
}` |
|
|
|
|
|
|
|
|