summaryrefslogtreecommitdiff
path: root/pkg/app/config.go
diff options
context:
space:
mode:
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)
+}