blob: a371beb68fe4c1d30608aca6f04b0eadcacfe5e4 (
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 {
Name string
PasswordHash []byte
Salt []byte
}
type Endpoint struct {
Path string
Address string
}
type Config struct {
ListenAddress string
AssetDirectory string
LoginTimeout int
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
}
|