diff options
| author | davy <davy.wybiral@gmail.com> | 2019-06-27 15:09:17 -0500 |
|---|---|---|
| committer | davy <davy.wybiral@gmail.com> | 2019-06-27 15:09:17 -0500 |
| commit | ef01f99df7dafc61c11203e879e997c15dea98ca (patch) | |
| tree | 19fc1aa07dd49c0134162ee5aec91032c6b242f5 /pkg/app/config.go | |
| parent | c615ea6b141571cfb04331d853af1acab829a9aa (diff) | |
added config.json
Diffstat (limited to 'pkg/app/config.go')
| -rw-r--r-- | pkg/app/config.go | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/pkg/app/config.go b/pkg/app/config.go new file mode 100644 index 0000000..c4ea170 --- /dev/null +++ b/pkg/app/config.go @@ -0,0 +1,36 @@ +package app + +import ( + "encoding/json" + "os" +) + +type Config struct { + LibraryPath string `json:"library"` + Server *ServerConfig `json:"server"` +} + +type ServerConfig struct { + Host string `json:"host"` + Port int `json:"port"` +} + +func DefaultConfig() *Config { + return &Config{ + LibraryPath: "videos", + Server: &ServerConfig{ + Host: "127.0.0.1", + Port: 0, + }, + } +} + +func (c *Config) ReadFile(path string) error { + f, err := os.Open(path) + if err != nil { + return err + } + defer f.Close() + d := json.NewDecoder(f) + return d.Decode(c) +} |
