summaryrefslogtreecommitdiff
path: root/pkg/app/config.go
diff options
context:
space:
mode:
authordavy <davy.wybiral@gmail.com>2019-06-27 15:09:17 -0500
committerdavy <davy.wybiral@gmail.com>2019-06-27 15:09:17 -0500
commitef01f99df7dafc61c11203e879e997c15dea98ca (patch)
tree19fc1aa07dd49c0134162ee5aec91032c6b242f5 /pkg/app/config.go
parentc615ea6b141571cfb04331d853af1acab829a9aa (diff)
added config.json
Diffstat (limited to 'pkg/app/config.go')
-rw-r--r--pkg/app/config.go36
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)
+}