summaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2023-05-13 22:32:24 -0500
committersanine <sanine.not@pm.me>2023-05-13 22:32:24 -0500
commit9571ccc4d87907067df98edeaa78f0c167fcff43 (patch)
treee64760fa34d7ecfd8460596b8ddf314ceacda2b7 /config
parent609ef3f3b4d4cb355d80b19df1e91db258b0bbe0 (diff)
begin total refactor
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
+}