-
Notifications
You must be signed in to change notification settings - Fork 10
/
config.go
43 lines (33 loc) · 1.04 KB
/
config.go
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 (
"encoding/json"
"os"
"code.cloudfoundry.org/debugserver"
loggingclient "code.cloudfoundry.org/diego-logging-client"
"code.cloudfoundry.org/lager/v3/lagerflags"
)
type FileServerConfig struct {
ServerAddress string `json:"server_address,omitempty"`
StaticDirectory string `json:"static_directory,omitempty"`
HTTPSServerEnabled bool `json:"https_server_enabled"`
HTTPSListenAddr string `json:"https_listen_addr"`
CertFile string `json:"cert_file"`
KeyFile string `json:"key_file"`
LoggregatorConfig loggingclient.Config `json:"loggregator"`
debugserver.DebugServerConfig
lagerflags.LagerConfig
}
func NewFileServerConfig(configPath string) (FileServerConfig, error) {
fileServerConfig := FileServerConfig{}
configFile, err := os.Open(configPath)
if err != nil {
return FileServerConfig{}, err
}
defer configFile.Close()
decoder := json.NewDecoder(configFile)
err = decoder.Decode(&fileServerConfig)
if err != nil {
return FileServerConfig{}, err
}
return fileServerConfig, nil
}