blob: 32855dc77be397b6f48f418bf0b013a78a4d7590 (
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
45
46
47
48
49
50
51
52
53
|
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
PathPrefix string
AssetDirectory string
LoginTimeout int
Users []User
Endpoints []Endpoint
}
type Api struct {
Prefix string
Login string
Logout string
Asset string
}
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
}
|