-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.go
More file actions
46 lines (37 loc) · 805 Bytes
/
Copy pathconfig.go
File metadata and controls
46 lines (37 loc) · 805 Bytes
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
package main
import (
"flag"
"fmt"
"github.com/BurntSushi/toml"
"github.com/zedeus/nitter-proxy/cache"
)
type Config struct {
Server ServerConfig
Config ConfigSection
Cache cache.Config
}
type ServerConfig struct {
Address string `toml:"address"`
Port int `toml:"port"`
}
type ConfigSection struct {
HMACKey string `toml:"hmacKey"`
}
func loadConfig() (*Config, error) {
path := flag.String("config", "nitter-proxy.conf", "path to config file")
flag.Parse()
cfg := &Config{
Server: ServerConfig{
Address: "localhost",
Port: 7000,
},
Config: ConfigSection{
HMACKey: "secretkey",
},
Cache: cache.DefaultConfig(),
}
if _, err := toml.DecodeFile(*path, cfg); err != nil {
return nil, fmt.Errorf("loading config %s: %w", *path, err)
}
return cfg, nil
}