summaryrefslogtreecommitdiff
path: root/config/config.go
blob: fe574a756df04c768f61a5768800504b321b7ef6 (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
package config

import (
	"os"
	"encoding/json"
)


type User struct {
	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
}