Browse Source

Add tags for json serialization to settings structs

feature/add-settings
Fabian Vowie 3 years ago
parent
commit
994677cf34
No known key found for this signature in database GPG Key ID: C27317C33B27C410
  1. 10
      settings/settings.go
  2. 4
      settings/settings_test.go

10
settings/settings.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 {

4
settings/settings_test.go

@ -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"
} }
}` }`

Loading…
Cancel
Save