summaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
Diffstat (limited to 'config')
-rw-r--r--config/config.go44
1 files changed, 44 insertions, 0 deletions
diff --git a/config/config.go b/config/config.go
new file mode 100644
index 0000000..8a22f9d
--- /dev/null
+++ b/config/config.go
@@ -0,0 +1,44 @@
+package config
+
+import (
+ "os"
+ "encoding/json"
+)
+
+
+type User struct {
+ Id string
+ Name string
+ PasswordHash []byte
+ Salt []byte
+}
+
+
+type Endpoint struct {
+ Path string
+ Address string
+}
+
+
+type Config struct {
+ ListenAddress string
+ AssetDirectory string
+ Users []User
+ Endpoints []Endpoint
+}
+
+
+func Load(filename string) (Config, error) {
+ blob, err := os.ReadFile(filename)
+ if err != nil {
+ return Config{}, err
+ }
+
+ config := Config{}
+ err = json.Unmarshal(blob, &config)
+ if err != nil {
+ return Config{}, err
+ }
+
+ return config, nil
+}