summaryrefslogtreecommitdiff
path: root/config/config.go
blob: 8a22f9dd3fdfc93d7a666ec4da6db6054df3b78b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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
}