From 9571ccc4d87907067df98edeaa78f0c167fcff43 Mon Sep 17 00:00:00 2001 From: sanine Date: Sat, 13 May 2023 22:32:24 -0500 Subject: begin total refactor --- config/config.go | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 config/config.go (limited to 'config') 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 +} -- cgit v1.2.1