Change http config to sub element
This commit is contained in:
@@ -8,14 +8,20 @@ import (
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
SiteName string `json:"siteName" toml:"siteName"`
|
||||
HTTPListenAddr string `json:"httpListenAddr" toml:"HTTPListenAddr"`
|
||||
SiteName string `toml:"siteName"`
|
||||
HTTP ConfigHTTP `toml:"http"`
|
||||
}
|
||||
|
||||
type ConfigHTTP struct {
|
||||
ListenAddr string `json:"ListenAddr" toml:"ListenAddr"`
|
||||
}
|
||||
|
||||
func DefaultConfig() *Config {
|
||||
return &Config{
|
||||
SiteName: "ministream",
|
||||
HTTPListenAddr: ":8080",
|
||||
SiteName: "ministream",
|
||||
HTTP: ConfigHTTP{
|
||||
ListenAddr: ":8080",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,8 +30,8 @@ func (c *Config) OverrideFromEnv() {
|
||||
c.SiteName = siteName
|
||||
}
|
||||
|
||||
if httpAddr, ok := os.LookupEnv("MINISTREAM_HTTPLISTENADDR"); ok {
|
||||
c.HTTPListenAddr = httpAddr
|
||||
if httpAddr, ok := os.LookupEnv("MINISTREAM_HTTP_LISTENADDR"); ok {
|
||||
c.HTTP.ListenAddr = httpAddr
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user