web
This commit is contained in:
@@ -110,6 +110,22 @@ func HttpListenConfigTLS(addr, caFile, certFile, keyFile string, router http.Han
|
||||
}
|
||||
}
|
||||
|
||||
func HttpListenWebServerTLS(addr, certFile, keyFile string) {
|
||||
err := http.ListenAndServeTLS(addr, certFile, keyFile, nil)
|
||||
if err != nil {
|
||||
fmt.Println("ListenAndServeTLS err:", err)
|
||||
os.Exit(7)
|
||||
}
|
||||
}
|
||||
|
||||
func HttpListenWebServer(addr string) {
|
||||
err := http.ListenAndServe(addr, nil)
|
||||
if err != nil {
|
||||
fmt.Println("ListenAndServe err:", err)
|
||||
os.Exit(7)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
conf := config.GetYamlConfig()
|
||||
|
||||
@@ -175,5 +191,17 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
if conf.WebServer.Enabled {
|
||||
fs := http.FileServer(http.Dir(conf.WebServer.RootDir))
|
||||
http.Handle("/", fs)
|
||||
for _, listen := range conf.WebServer.Listen {
|
||||
if strings.ToLower(listen.Schema) == "https" {
|
||||
go HttpListenWebServerTLS(listen.Addr, listen.CertFile, listen.KeyFile)
|
||||
} else {
|
||||
go HttpListenWebServer(listen.Addr)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
select {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user